documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5120. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. 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;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. 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;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. 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;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. 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);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * 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;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * 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).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * 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).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * 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.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * 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.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * 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.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * 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.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * 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).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * 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).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * 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.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * 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.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * 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.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * 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.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * 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).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * 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).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * 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.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * 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.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * 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.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * 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.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * 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.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * 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).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * 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).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * 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.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * 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.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * 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.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * 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.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: AbstractActionManager;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * 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
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @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
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @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
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @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
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @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
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. private _useInstancing;
  11027. /**
  11028. * An event triggered when the manager is disposed.
  11029. */
  11030. onDisposeObservable: Observable<SpriteManager>;
  11031. private _onDisposeObserver;
  11032. /**
  11033. * Callback called when the manager is disposed
  11034. */
  11035. set onDispose(callback: () => void);
  11036. private _capacity;
  11037. private _fromPacked;
  11038. private _spriteTexture;
  11039. private _epsilon;
  11040. private _scene;
  11041. private _vertexData;
  11042. private _buffer;
  11043. private _vertexBuffers;
  11044. private _spriteBuffer;
  11045. private _indexBuffer;
  11046. private _effectBase;
  11047. private _effectFog;
  11048. private _vertexBufferSize;
  11049. /**
  11050. * Gets or sets the unique id of the sprite
  11051. */
  11052. uniqueId: number;
  11053. /**
  11054. * Gets the array of sprites
  11055. */
  11056. get children(): Sprite[];
  11057. /**
  11058. * Gets the hosting scene
  11059. */
  11060. get scene(): Scene;
  11061. /**
  11062. * Gets the capacity of the manager
  11063. */
  11064. get capacity(): number;
  11065. /**
  11066. * Gets or sets the spritesheet texture
  11067. */
  11068. get texture(): Texture;
  11069. set texture(value: Texture);
  11070. private _blendMode;
  11071. /**
  11072. * Blend mode use to render the particle, it can be any of
  11073. * the static Constants.ALPHA_x properties provided in this class.
  11074. * Default value is Constants.ALPHA_COMBINE
  11075. */
  11076. get blendMode(): number;
  11077. set blendMode(blendMode: number);
  11078. /** Disables writing to the depth buffer when rendering the sprites.
  11079. * It can be handy to disable depth writing when using textures without alpha channel
  11080. * and setting some specific blend modes.
  11081. */
  11082. disableDepthWrite: boolean;
  11083. /**
  11084. * Creates a new sprite manager
  11085. * @param name defines the manager's name
  11086. * @param imgUrl defines the sprite sheet url
  11087. * @param capacity defines the maximum allowed number of sprites
  11088. * @param cellSize defines the size of a sprite cell
  11089. * @param scene defines the hosting scene
  11090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11091. * @param samplingMode defines the smapling mode to use with spritesheet
  11092. * @param fromPacked set to false; do not alter
  11093. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11094. */
  11095. constructor(
  11096. /** defines the manager's name */
  11097. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11098. /**
  11099. * Returns the string "SpriteManager"
  11100. * @returns "SpriteManager"
  11101. */
  11102. getClassName(): string;
  11103. private _makePacked;
  11104. private _appendSpriteVertex;
  11105. private _checkTextureAlpha;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11112. * @returns null if no hit or a PickingInfo
  11113. */
  11114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11115. /**
  11116. * Intersects the sprites with a ray
  11117. * @param ray defines the ray to intersect with
  11118. * @param camera defines the current active camera
  11119. * @param predicate defines a predicate used to select candidate sprites
  11120. * @returns null if no hit or a PickingInfo array
  11121. */
  11122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11123. /**
  11124. * Render all child sprites
  11125. */
  11126. render(): void;
  11127. /**
  11128. * Release associated resources
  11129. */
  11130. dispose(): void;
  11131. /**
  11132. * Serializes the sprite manager to a JSON object
  11133. * @param serializeTexture defines if the texture must be serialized as well
  11134. * @returns the JSON object
  11135. */
  11136. serialize(serializeTexture?: boolean): any;
  11137. /**
  11138. * Parses a JSON object to create a new sprite manager.
  11139. * @param parsedManager The JSON object to parse
  11140. * @param scene The scene to create the sprite managerin
  11141. * @param rootUrl The root url to use to load external dependencies like texture
  11142. * @returns the new sprite manager
  11143. */
  11144. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11145. /**
  11146. * Creates a sprite manager from a snippet saved in a remote file
  11147. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11148. * @param url defines the url to load from
  11149. * @param scene defines the hosting scene
  11150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11151. * @returns a promise that will resolve to the new sprite manager
  11152. */
  11153. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11154. /**
  11155. * Creates a sprite manager from a snippet saved by the sprite editor
  11156. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11157. * @param scene defines the hosting scene
  11158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11159. * @returns a promise that will resolve to the new sprite manager
  11160. */
  11161. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. /** Interface used by value gradients (color, factor, ...) */
  11166. export interface IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. }
  11172. /** Class used to store color4 gradient */
  11173. export class ColorGradient implements IValueGradient {
  11174. /**
  11175. * Gets or sets the gradient value (between 0 and 1)
  11176. */
  11177. gradient: number;
  11178. /**
  11179. * Gets or sets first associated color
  11180. */
  11181. color1: Color4;
  11182. /**
  11183. * Gets or sets second associated color
  11184. */
  11185. color2?: Color4 | undefined;
  11186. /**
  11187. * Creates a new color4 gradient
  11188. * @param gradient gets or sets the gradient value (between 0 and 1)
  11189. * @param color1 gets or sets first associated color
  11190. * @param color2 gets or sets first second color
  11191. */
  11192. constructor(
  11193. /**
  11194. * Gets or sets the gradient value (between 0 and 1)
  11195. */
  11196. gradient: number,
  11197. /**
  11198. * Gets or sets first associated color
  11199. */
  11200. color1: Color4,
  11201. /**
  11202. * Gets or sets second associated color
  11203. */
  11204. color2?: Color4 | undefined);
  11205. /**
  11206. * Will get a color picked randomly between color1 and color2.
  11207. * If color2 is undefined then color1 will be used
  11208. * @param result defines the target Color4 to store the result in
  11209. */
  11210. getColorToRef(result: Color4): void;
  11211. }
  11212. /** Class used to store color 3 gradient */
  11213. export class Color3Gradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets the associated color
  11220. */
  11221. color: Color3;
  11222. /**
  11223. * Creates a new color3 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color gets or sets associated color
  11226. */
  11227. constructor(
  11228. /**
  11229. * Gets or sets the gradient value (between 0 and 1)
  11230. */
  11231. gradient: number,
  11232. /**
  11233. * Gets or sets the associated color
  11234. */
  11235. color: Color3);
  11236. }
  11237. /** Class used to store factor gradient */
  11238. export class FactorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated factor
  11245. */
  11246. factor1: number;
  11247. /**
  11248. * Gets or sets second associated factor
  11249. */
  11250. factor2?: number | undefined;
  11251. /**
  11252. * Creates a new factor gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param factor1 gets or sets first associated factor
  11255. * @param factor2 gets or sets second associated factor
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated factor
  11264. */
  11265. factor1: number,
  11266. /**
  11267. * Gets or sets second associated factor
  11268. */
  11269. factor2?: number | undefined);
  11270. /**
  11271. * Will get a number picked randomly between factor1 and factor2.
  11272. * If factor2 is undefined then factor1 will be used
  11273. * @returns the picked number
  11274. */
  11275. getFactor(): number;
  11276. }
  11277. /**
  11278. * Helper used to simplify some generic gradient tasks
  11279. */
  11280. export class GradientHelper {
  11281. /**
  11282. * Gets the current gradient from an array of IValueGradient
  11283. * @param ratio defines the current ratio to get
  11284. * @param gradients defines the array of IValueGradient
  11285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11286. */
  11287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11288. }
  11289. }
  11290. declare module BABYLON {
  11291. interface ThinEngine {
  11292. /**
  11293. * Creates a raw texture
  11294. * @param data defines the data to store in the texture
  11295. * @param width defines the width of the texture
  11296. * @param height defines the height of the texture
  11297. * @param format defines the format of the data
  11298. * @param generateMipMaps defines if the engine should generate the mip levels
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. * @returns the raw texture inside an InternalTexture
  11304. */
  11305. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11306. /**
  11307. * Update a raw texture
  11308. * @param texture defines the texture to update
  11309. * @param data defines the data to store in the texture
  11310. * @param format defines the format of the data
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. */
  11313. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11314. /**
  11315. * Update a raw texture
  11316. * @param texture defines the texture to update
  11317. * @param data defines the data to store in the texture
  11318. * @param format defines the format of the data
  11319. * @param invertY defines if data must be stored with Y axis inverted
  11320. * @param compression defines the compression used (null by default)
  11321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11322. */
  11323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11324. /**
  11325. * Creates a new raw cube texture
  11326. * @param data defines the array of data to use to create each face
  11327. * @param size defines the size of the textures
  11328. * @param format defines the format of the data
  11329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11330. * @param generateMipMaps defines if the engine should generate the mip levels
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11333. * @param compression defines the compression used (null by default)
  11334. * @returns the cube texture as an InternalTexture
  11335. */
  11336. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. */
  11345. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11346. /**
  11347. * Update a raw cube texture
  11348. * @param texture defines the texture to udpdate
  11349. * @param data defines the data to store
  11350. * @param format defines the data format
  11351. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the compression used (null by default)
  11354. */
  11355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11356. /**
  11357. * Update a raw cube texture
  11358. * @param texture defines the texture to udpdate
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. * @param invertY defines if data must be stored with Y axis inverted
  11363. * @param compression defines the compression used (null by default)
  11364. * @param level defines which level of the texture to update
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11367. /**
  11368. * Creates a new raw cube texture from a specified url
  11369. * @param url defines the url where the data is located
  11370. * @param scene defines the current scene
  11371. * @param size defines the size of the textures
  11372. * @param format defines the format of the data
  11373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11374. * @param noMipmap defines if the engine should avoid generating the mip levels
  11375. * @param callback defines a callback used to extract texture data from loaded data
  11376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11377. * @param onLoad defines a callback called when texture is loaded
  11378. * @param onError defines a callback called if there is an error
  11379. * @returns the cube texture as an InternalTexture
  11380. */
  11381. 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;
  11382. /**
  11383. * Creates a new raw cube texture from a specified url
  11384. * @param url defines the url where the data is located
  11385. * @param scene defines the current scene
  11386. * @param size defines the size of the textures
  11387. * @param format defines the format of the data
  11388. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11389. * @param noMipmap defines if the engine should avoid generating the mip levels
  11390. * @param callback defines a callback used to extract texture data from loaded data
  11391. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11392. * @param onLoad defines a callback called when texture is loaded
  11393. * @param onError defines a callback called if there is an error
  11394. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11395. * @param invertY defines if data must be stored with Y axis inverted
  11396. * @returns the cube texture as an InternalTexture
  11397. */
  11398. 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;
  11399. /**
  11400. * Creates a new raw 3D texture
  11401. * @param data defines the data used to create the texture
  11402. * @param width defines the width of the texture
  11403. * @param height defines the height of the texture
  11404. * @param depth defines the depth of the texture
  11405. * @param format defines the format of the texture
  11406. * @param generateMipMaps defines if the engine must generate mip levels
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11409. * @param compression defines the compressed used (can be null)
  11410. * @param textureType defines the compressed used (can be null)
  11411. * @returns a new raw 3D texture (stored in an InternalTexture)
  11412. */
  11413. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11414. /**
  11415. * Update a raw 3D texture
  11416. * @param texture defines the texture to update
  11417. * @param data defines the data to store
  11418. * @param format defines the data format
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. */
  11421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11422. /**
  11423. * Update a raw 3D texture
  11424. * @param texture defines the texture to update
  11425. * @param data defines the data to store
  11426. * @param format defines the data format
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the used compression (can be null)
  11429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11430. */
  11431. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11432. /**
  11433. * Creates a new raw 2D array texture
  11434. * @param data defines the data used to create the texture
  11435. * @param width defines the width of the texture
  11436. * @param height defines the height of the texture
  11437. * @param depth defines the number of layers of the texture
  11438. * @param format defines the format of the texture
  11439. * @param generateMipMaps defines if the engine must generate mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11442. * @param compression defines the compressed used (can be null)
  11443. * @param textureType defines the compressed used (can be null)
  11444. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11445. */
  11446. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11447. /**
  11448. * Update a raw 2D array texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store
  11451. * @param format defines the data format
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw 2D array texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store
  11459. * @param format defines the data format
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the used compression (can be null)
  11462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11463. */
  11464. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * Raw texture can help creating a texture directly from an array of data.
  11470. * This can be super useful if you either get the data from an uncompressed source or
  11471. * if you wish to create your texture pixel by pixel.
  11472. */
  11473. export class RawTexture extends Texture {
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number;
  11478. /**
  11479. * Instantiates a new RawTexture.
  11480. * Raw texture can help creating a texture directly from an array of data.
  11481. * This can be super useful if you either get the data from an uncompressed source or
  11482. * if you wish to create your texture pixel by pixel.
  11483. * @param data define the array of data to use to create the texture
  11484. * @param width define the width of the texture
  11485. * @param height define the height of the texture
  11486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11487. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11488. * @param generateMipMaps define whether mip maps should be generated or not
  11489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11492. */
  11493. constructor(data: ArrayBufferView, width: number, height: number,
  11494. /**
  11495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11496. */
  11497. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11498. /**
  11499. * Updates the texture underlying data.
  11500. * @param data Define the new data of the texture
  11501. */
  11502. update(data: ArrayBufferView): void;
  11503. /**
  11504. * Creates a luminance texture from some data.
  11505. * @param data Define the texture data
  11506. * @param width Define the width of the texture
  11507. * @param height Define the height of the texture
  11508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @returns the luminance texture
  11513. */
  11514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11515. /**
  11516. * Creates a luminance alpha texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance alpha texture
  11525. */
  11526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates an alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the alpha texture
  11537. */
  11538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates a RGB texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11549. * @returns the RGB alpha texture
  11550. */
  11551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11552. /**
  11553. * Creates a RGBA texture from some data.
  11554. * @param data Define the texture data
  11555. * @param width Define the width of the texture
  11556. * @param height Define the height of the texture
  11557. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11562. * @returns the RGBA texture
  11563. */
  11564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11565. /**
  11566. * Creates a R texture from some data.
  11567. * @param data Define the texture data
  11568. * @param width Define the width of the texture
  11569. * @param height Define the height of the texture
  11570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11575. * @returns the R texture
  11576. */
  11577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. interface ThinEngine {
  11582. /**
  11583. * Update a dynamic index buffer
  11584. * @param indexBuffer defines the target index buffer
  11585. * @param indices defines the data to update
  11586. * @param offset defines the offset in the target index buffer where update should start
  11587. */
  11588. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11589. /**
  11590. * Updates a dynamic vertex buffer.
  11591. * @param vertexBuffer the vertex buffer to update
  11592. * @param data the data used to update the vertex buffer
  11593. * @param byteOffset the byte offset of the data
  11594. * @param byteLength the byte length of the data
  11595. */
  11596. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. interface AbstractScene {
  11601. /**
  11602. * The list of procedural textures added to the scene
  11603. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11604. */
  11605. proceduralTextures: Array<ProceduralTexture>;
  11606. }
  11607. /**
  11608. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11609. * in a given scene.
  11610. */
  11611. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /**
  11621. * Creates a new instance of the component for the given scene
  11622. * @param scene Defines the scene to register the component in
  11623. */
  11624. constructor(scene: Scene);
  11625. /**
  11626. * Registers the component in a given scene
  11627. */
  11628. register(): void;
  11629. /**
  11630. * Rebuilds the elements related to this component in case of
  11631. * context lost for instance.
  11632. */
  11633. rebuild(): void;
  11634. /**
  11635. * Disposes the component and the associated ressources.
  11636. */
  11637. dispose(): void;
  11638. private _beforeClear;
  11639. }
  11640. }
  11641. declare module BABYLON {
  11642. interface ThinEngine {
  11643. /**
  11644. * Creates a new render target cube texture
  11645. * @param size defines the size of the texture
  11646. * @param options defines the options used to create the texture
  11647. * @returns a new render target cube texture stored in an InternalTexture
  11648. */
  11649. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var proceduralVertexShader: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /**
  11661. * 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.
  11662. * This is the base class of any Procedural texture and contains most of the shareable code.
  11663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11664. */
  11665. export class ProceduralTexture extends Texture {
  11666. isCube: boolean;
  11667. /**
  11668. * Define if the texture is enabled or not (disabled texture will not render)
  11669. */
  11670. isEnabled: boolean;
  11671. /**
  11672. * Define if the texture must be cleared before rendering (default is true)
  11673. */
  11674. autoClear: boolean;
  11675. /**
  11676. * Callback called when the texture is generated
  11677. */
  11678. onGenerated: () => void;
  11679. /**
  11680. * Event raised when the texture is generated
  11681. */
  11682. onGeneratedObservable: Observable<ProceduralTexture>;
  11683. /** @hidden */
  11684. _generateMipMaps: boolean;
  11685. /** @hidden **/
  11686. _effect: Effect;
  11687. /** @hidden */
  11688. _textures: {
  11689. [key: string]: Texture;
  11690. };
  11691. /** @hidden */
  11692. protected _fallbackTexture: Nullable<Texture>;
  11693. private _size;
  11694. private _currentRefreshId;
  11695. private _frameId;
  11696. private _refreshRate;
  11697. private _vertexBuffers;
  11698. private _indexBuffer;
  11699. private _uniforms;
  11700. private _samplers;
  11701. private _fragment;
  11702. private _floats;
  11703. private _ints;
  11704. private _floatsArrays;
  11705. private _colors3;
  11706. private _colors4;
  11707. private _vectors2;
  11708. private _vectors3;
  11709. private _matrices;
  11710. private _fallbackTextureUsed;
  11711. private _fullEngine;
  11712. private _cachedDefines;
  11713. private _contentUpdateId;
  11714. private _contentData;
  11715. /**
  11716. * Instantiates a new procedural texture.
  11717. * 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.
  11718. * This is the base class of any Procedural texture and contains most of the shareable code.
  11719. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11720. * @param name Define the name of the texture
  11721. * @param size Define the size of the texture to create
  11722. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11723. * @param scene Define the scene the texture belongs to
  11724. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11725. * @param generateMipMaps Define if the texture should creates mip maps or not
  11726. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11727. */
  11728. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11729. /**
  11730. * The effect that is created when initializing the post process.
  11731. * @returns The created effect corresponding the the postprocess.
  11732. */
  11733. getEffect(): Effect;
  11734. /**
  11735. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11736. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11737. */
  11738. getContent(): Nullable<ArrayBufferView>;
  11739. private _createIndexBuffer;
  11740. /** @hidden */
  11741. _rebuild(): void;
  11742. /**
  11743. * Resets the texture in order to recreate its associated resources.
  11744. * This can be called in case of context loss
  11745. */
  11746. reset(): void;
  11747. protected _getDefines(): string;
  11748. /**
  11749. * Is the texture ready to be used ? (rendered at least once)
  11750. * @returns true if ready, otherwise, false.
  11751. */
  11752. isReady(): boolean;
  11753. /**
  11754. * Resets the refresh counter of the texture and start bak from scratch.
  11755. * Could be useful to regenerate the texture if it is setup to render only once.
  11756. */
  11757. resetRefreshCounter(): void;
  11758. /**
  11759. * Set the fragment shader to use in order to render the texture.
  11760. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11761. */
  11762. setFragment(fragment: any): void;
  11763. /**
  11764. * Define the refresh rate of the texture or the rendering frequency.
  11765. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11766. */
  11767. get refreshRate(): number;
  11768. set refreshRate(value: number);
  11769. /** @hidden */
  11770. _shouldRender(): boolean;
  11771. /**
  11772. * Get the size the texture is rendering at.
  11773. * @returns the size (texture is always squared)
  11774. */
  11775. getRenderSize(): number;
  11776. /**
  11777. * Resize the texture to new value.
  11778. * @param size Define the new size the texture should have
  11779. * @param generateMipMaps Define whether the new texture should create mip maps
  11780. */
  11781. resize(size: number, generateMipMaps: boolean): void;
  11782. private _checkUniform;
  11783. /**
  11784. * Set a texture in the shader program used to render.
  11785. * @param name Define the name of the uniform samplers as defined in the shader
  11786. * @param texture Define the texture to bind to this sampler
  11787. * @return the texture itself allowing "fluent" like uniform updates
  11788. */
  11789. setTexture(name: string, texture: Texture): ProceduralTexture;
  11790. /**
  11791. * Set a float in the shader.
  11792. * @param name Define the name of the uniform as defined in the shader
  11793. * @param value Define the value to give to the uniform
  11794. * @return the texture itself allowing "fluent" like uniform updates
  11795. */
  11796. setFloat(name: string, value: number): ProceduralTexture;
  11797. /**
  11798. * Set a int in the shader.
  11799. * @param name Define the name of the uniform as defined in the shader
  11800. * @param value Define the value to give to the uniform
  11801. * @return the texture itself allowing "fluent" like uniform updates
  11802. */
  11803. setInt(name: string, value: number): ProceduralTexture;
  11804. /**
  11805. * Set an array of floats in the shader.
  11806. * @param name Define the name of the uniform as defined in the shader
  11807. * @param value Define the value to give to the uniform
  11808. * @return the texture itself allowing "fluent" like uniform updates
  11809. */
  11810. setFloats(name: string, value: number[]): ProceduralTexture;
  11811. /**
  11812. * Set a vec3 in the shader from a Color3.
  11813. * @param name Define the name of the uniform as defined in the shader
  11814. * @param value Define the value to give to the uniform
  11815. * @return the texture itself allowing "fluent" like uniform updates
  11816. */
  11817. setColor3(name: string, value: Color3): ProceduralTexture;
  11818. /**
  11819. * Set a vec4 in the shader from a Color4.
  11820. * @param name Define the name of the uniform as defined in the shader
  11821. * @param value Define the value to give to the uniform
  11822. * @return the texture itself allowing "fluent" like uniform updates
  11823. */
  11824. setColor4(name: string, value: Color4): ProceduralTexture;
  11825. /**
  11826. * Set a vec2 in the shader from a Vector2.
  11827. * @param name Define the name of the uniform as defined in the shader
  11828. * @param value Define the value to give to the uniform
  11829. * @return the texture itself allowing "fluent" like uniform updates
  11830. */
  11831. setVector2(name: string, value: Vector2): ProceduralTexture;
  11832. /**
  11833. * Set a vec3 in the shader from a Vector3.
  11834. * @param name Define the name of the uniform as defined in the shader
  11835. * @param value Define the value to give to the uniform
  11836. * @return the texture itself allowing "fluent" like uniform updates
  11837. */
  11838. setVector3(name: string, value: Vector3): ProceduralTexture;
  11839. /**
  11840. * Set a mat4 in the shader from a MAtrix.
  11841. * @param name Define the name of the uniform as defined in the shader
  11842. * @param value Define the value to give to the uniform
  11843. * @return the texture itself allowing "fluent" like uniform updates
  11844. */
  11845. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11846. /**
  11847. * Render the texture to its associated render target.
  11848. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11849. */
  11850. render(useCameraPostProcess?: boolean): void;
  11851. /**
  11852. * Clone the texture.
  11853. * @returns the cloned texture
  11854. */
  11855. clone(): ProceduralTexture;
  11856. /**
  11857. * Dispose the texture and release its asoociated resources.
  11858. */
  11859. dispose(): void;
  11860. }
  11861. }
  11862. declare module BABYLON {
  11863. /**
  11864. * This represents the base class for particle system in Babylon.
  11865. * 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.
  11866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11867. * @example https://doc.babylonjs.com/babylon101/particles
  11868. */
  11869. export class BaseParticleSystem {
  11870. /**
  11871. * Source color is added to the destination color without alpha affecting the result
  11872. */
  11873. static BLENDMODE_ONEONE: number;
  11874. /**
  11875. * Blend current color and particle color using particle’s alpha
  11876. */
  11877. static BLENDMODE_STANDARD: number;
  11878. /**
  11879. * Add current color and particle color multiplied by particle’s alpha
  11880. */
  11881. static BLENDMODE_ADD: number;
  11882. /**
  11883. * Multiply current color with particle color
  11884. */
  11885. static BLENDMODE_MULTIPLY: number;
  11886. /**
  11887. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11888. */
  11889. static BLENDMODE_MULTIPLYADD: number;
  11890. /**
  11891. * List of animations used by the particle system.
  11892. */
  11893. animations: Animation[];
  11894. /**
  11895. * Gets or sets the unique id of the particle system
  11896. */
  11897. uniqueId: number;
  11898. /**
  11899. * The id of the Particle system.
  11900. */
  11901. id: string;
  11902. /**
  11903. * The friendly name of the Particle system.
  11904. */
  11905. name: string;
  11906. /**
  11907. * Snippet ID if the particle system was created from the snippet server
  11908. */
  11909. snippetId: string;
  11910. /**
  11911. * The rendering group used by the Particle system to chose when to render.
  11912. */
  11913. renderingGroupId: number;
  11914. /**
  11915. * The emitter represents the Mesh or position we are attaching the particle system to.
  11916. */
  11917. emitter: Nullable<AbstractMesh | Vector3>;
  11918. /**
  11919. * The maximum number of particles to emit per frame
  11920. */
  11921. emitRate: number;
  11922. /**
  11923. * If you want to launch only a few particles at once, that can be done, as well.
  11924. */
  11925. manualEmitCount: number;
  11926. /**
  11927. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11928. */
  11929. updateSpeed: number;
  11930. /**
  11931. * The amount of time the particle system is running (depends of the overall update speed).
  11932. */
  11933. targetStopDuration: number;
  11934. /**
  11935. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11936. */
  11937. disposeOnStop: boolean;
  11938. /**
  11939. * Minimum power of emitting particles.
  11940. */
  11941. minEmitPower: number;
  11942. /**
  11943. * Maximum power of emitting particles.
  11944. */
  11945. maxEmitPower: number;
  11946. /**
  11947. * Minimum life time of emitting particles.
  11948. */
  11949. minLifeTime: number;
  11950. /**
  11951. * Maximum life time of emitting particles.
  11952. */
  11953. maxLifeTime: number;
  11954. /**
  11955. * Minimum Size of emitting particles.
  11956. */
  11957. minSize: number;
  11958. /**
  11959. * Maximum Size of emitting particles.
  11960. */
  11961. maxSize: number;
  11962. /**
  11963. * Minimum scale of emitting particles on X axis.
  11964. */
  11965. minScaleX: number;
  11966. /**
  11967. * Maximum scale of emitting particles on X axis.
  11968. */
  11969. maxScaleX: number;
  11970. /**
  11971. * Minimum scale of emitting particles on Y axis.
  11972. */
  11973. minScaleY: number;
  11974. /**
  11975. * Maximum scale of emitting particles on Y axis.
  11976. */
  11977. maxScaleY: number;
  11978. /**
  11979. * Gets or sets the minimal initial rotation in radians.
  11980. */
  11981. minInitialRotation: number;
  11982. /**
  11983. * Gets or sets the maximal initial rotation in radians.
  11984. */
  11985. maxInitialRotation: number;
  11986. /**
  11987. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11988. */
  11989. minAngularSpeed: number;
  11990. /**
  11991. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11992. */
  11993. maxAngularSpeed: number;
  11994. /**
  11995. * The texture used to render each particle. (this can be a spritesheet)
  11996. */
  11997. particleTexture: Nullable<BaseTexture>;
  11998. /**
  11999. * The layer mask we are rendering the particles through.
  12000. */
  12001. layerMask: number;
  12002. /**
  12003. * This can help using your own shader to render the particle system.
  12004. * The according effect will be created
  12005. */
  12006. customShader: any;
  12007. /**
  12008. * By default particle system starts as soon as they are created. This prevents the
  12009. * automatic start to happen and let you decide when to start emitting particles.
  12010. */
  12011. preventAutoStart: boolean;
  12012. private _noiseTexture;
  12013. /**
  12014. * Gets or sets a texture used to add random noise to particle positions
  12015. */
  12016. get noiseTexture(): Nullable<ProceduralTexture>;
  12017. set noiseTexture(value: Nullable<ProceduralTexture>);
  12018. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12019. noiseStrength: Vector3;
  12020. /**
  12021. * Callback triggered when the particle animation is ending.
  12022. */
  12023. onAnimationEnd: Nullable<() => void>;
  12024. /**
  12025. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12026. */
  12027. blendMode: number;
  12028. /**
  12029. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12030. * to override the particles.
  12031. */
  12032. forceDepthWrite: boolean;
  12033. /** 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 */
  12034. preWarmCycles: number;
  12035. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12036. preWarmStepOffset: number;
  12037. /**
  12038. * 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)
  12039. */
  12040. spriteCellChangeSpeed: number;
  12041. /**
  12042. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12043. */
  12044. startSpriteCellID: number;
  12045. /**
  12046. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12047. */
  12048. endSpriteCellID: number;
  12049. /**
  12050. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12051. */
  12052. spriteCellWidth: number;
  12053. /**
  12054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12055. */
  12056. spriteCellHeight: number;
  12057. /**
  12058. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12059. */
  12060. spriteRandomStartCell: boolean;
  12061. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12062. translationPivot: Vector2;
  12063. /** @hidden */
  12064. protected _isAnimationSheetEnabled: boolean;
  12065. /**
  12066. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12067. */
  12068. beginAnimationOnStart: boolean;
  12069. /**
  12070. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12071. */
  12072. beginAnimationFrom: number;
  12073. /**
  12074. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12075. */
  12076. beginAnimationTo: number;
  12077. /**
  12078. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12079. */
  12080. beginAnimationLoop: boolean;
  12081. /**
  12082. * Gets or sets a world offset applied to all particles
  12083. */
  12084. worldOffset: Vector3;
  12085. /**
  12086. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12087. */
  12088. get isAnimationSheetEnabled(): boolean;
  12089. set isAnimationSheetEnabled(value: boolean);
  12090. /**
  12091. * Get hosting scene
  12092. * @returns the scene
  12093. */
  12094. getScene(): Nullable<Scene>;
  12095. /**
  12096. * You can use gravity if you want to give an orientation to your particles.
  12097. */
  12098. gravity: Vector3;
  12099. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12100. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12102. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12103. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12105. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12106. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12107. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12108. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12109. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12111. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12112. /**
  12113. * Defines the delay in milliseconds before starting the system (0 by default)
  12114. */
  12115. startDelay: number;
  12116. /**
  12117. * Gets the current list of drag gradients.
  12118. * You must use addDragGradient and removeDragGradient to udpate this list
  12119. * @returns the list of drag gradients
  12120. */
  12121. getDragGradients(): Nullable<Array<FactorGradient>>;
  12122. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12123. limitVelocityDamping: number;
  12124. /**
  12125. * Gets the current list of limit velocity gradients.
  12126. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12127. * @returns the list of limit velocity gradients
  12128. */
  12129. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12130. /**
  12131. * Gets the current list of color gradients.
  12132. * You must use addColorGradient and removeColorGradient to udpate this list
  12133. * @returns the list of color gradients
  12134. */
  12135. getColorGradients(): Nullable<Array<ColorGradient>>;
  12136. /**
  12137. * Gets the current list of size gradients.
  12138. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12139. * @returns the list of size gradients
  12140. */
  12141. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12142. /**
  12143. * Gets the current list of color remap gradients.
  12144. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12145. * @returns the list of color remap gradients
  12146. */
  12147. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12148. /**
  12149. * Gets the current list of alpha remap gradients.
  12150. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12151. * @returns the list of alpha remap gradients
  12152. */
  12153. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12154. /**
  12155. * Gets the current list of life time gradients.
  12156. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12157. * @returns the list of life time gradients
  12158. */
  12159. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12160. /**
  12161. * Gets the current list of angular speed gradients.
  12162. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12163. * @returns the list of angular speed gradients
  12164. */
  12165. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12166. /**
  12167. * Gets the current list of velocity gradients.
  12168. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12169. * @returns the list of velocity gradients
  12170. */
  12171. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12172. /**
  12173. * Gets the current list of start size gradients.
  12174. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12175. * @returns the list of start size gradients
  12176. */
  12177. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12178. /**
  12179. * Gets the current list of emit rate gradients.
  12180. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12181. * @returns the list of emit rate gradients
  12182. */
  12183. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12184. /**
  12185. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12186. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12187. */
  12188. get direction1(): Vector3;
  12189. set direction1(value: Vector3);
  12190. /**
  12191. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12192. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12193. */
  12194. get direction2(): Vector3;
  12195. set direction2(value: Vector3);
  12196. /**
  12197. * 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.
  12198. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12199. */
  12200. get minEmitBox(): Vector3;
  12201. set minEmitBox(value: Vector3);
  12202. /**
  12203. * 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.
  12204. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12205. */
  12206. get maxEmitBox(): Vector3;
  12207. set maxEmitBox(value: Vector3);
  12208. /**
  12209. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12210. */
  12211. color1: Color4;
  12212. /**
  12213. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12214. */
  12215. color2: Color4;
  12216. /**
  12217. * Color the particle will have at the end of its lifetime
  12218. */
  12219. colorDead: Color4;
  12220. /**
  12221. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12222. */
  12223. textureMask: Color4;
  12224. /**
  12225. * The particle emitter type defines the emitter used by the particle system.
  12226. * It can be for example box, sphere, or cone...
  12227. */
  12228. particleEmitterType: IParticleEmitterType;
  12229. /** @hidden */
  12230. _isSubEmitter: boolean;
  12231. /**
  12232. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12233. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12234. */
  12235. billboardMode: number;
  12236. protected _isBillboardBased: boolean;
  12237. /**
  12238. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12239. */
  12240. get isBillboardBased(): boolean;
  12241. set isBillboardBased(value: boolean);
  12242. /**
  12243. * The scene the particle system belongs to.
  12244. */
  12245. protected _scene: Nullable<Scene>;
  12246. /**
  12247. * The engine the particle system belongs to.
  12248. */
  12249. protected _engine: ThinEngine;
  12250. /**
  12251. * Local cache of defines for image processing.
  12252. */
  12253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12254. /**
  12255. * Default configuration related to image processing available in the standard Material.
  12256. */
  12257. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12258. /**
  12259. * Gets the image processing configuration used either in this material.
  12260. */
  12261. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12262. /**
  12263. * Sets the Default image processing configuration used either in the this material.
  12264. *
  12265. * If sets to null, the scene one is in use.
  12266. */
  12267. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12268. /**
  12269. * Attaches a new image processing configuration to the Standard Material.
  12270. * @param configuration
  12271. */
  12272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12273. /** @hidden */
  12274. protected _reset(): void;
  12275. /** @hidden */
  12276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12277. /**
  12278. * Instantiates a particle system.
  12279. * 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.
  12280. * @param name The name of the particle system
  12281. */
  12282. constructor(name: string);
  12283. /**
  12284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12287. * @returns the emitter
  12288. */
  12289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12290. /**
  12291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12292. * @param radius The radius of the hemisphere to emit from
  12293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12294. * @returns the emitter
  12295. */
  12296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12297. /**
  12298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12299. * @param radius The radius of the sphere to emit from
  12300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12301. * @returns the emitter
  12302. */
  12303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12304. /**
  12305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12306. * @param radius The radius of the sphere to emit from
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12309. * @returns the emitter
  12310. */
  12311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12314. * @param radius The radius of the emission cylinder
  12315. * @param height The height of the emission cylinder
  12316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12318. * @returns the emitter
  12319. */
  12320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12321. /**
  12322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12323. * @param radius The radius of the cylinder to emit from
  12324. * @param height The height of the emission cylinder
  12325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12328. * @returns the emitter
  12329. */
  12330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12331. /**
  12332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12333. * @param radius The radius of the cone to emit from
  12334. * @param angle The base angle of the cone
  12335. * @returns the emitter
  12336. */
  12337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12338. /**
  12339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12344. * @returns the emitter
  12345. */
  12346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12347. }
  12348. }
  12349. declare module BABYLON {
  12350. /**
  12351. * Type of sub emitter
  12352. */
  12353. export enum SubEmitterType {
  12354. /**
  12355. * Attached to the particle over it's lifetime
  12356. */
  12357. ATTACHED = 0,
  12358. /**
  12359. * Created when the particle dies
  12360. */
  12361. END = 1
  12362. }
  12363. /**
  12364. * Sub emitter class used to emit particles from an existing particle
  12365. */
  12366. export class SubEmitter {
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem;
  12371. /**
  12372. * Type of the submitter (Default: END)
  12373. */
  12374. type: SubEmitterType;
  12375. /**
  12376. * 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)
  12377. * Note: This only is supported when using an emitter of type Mesh
  12378. */
  12379. inheritDirection: boolean;
  12380. /**
  12381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12382. */
  12383. inheritedVelocityAmount: number;
  12384. /**
  12385. * Creates a sub emitter
  12386. * @param particleSystem the particle system to be used by the sub emitter
  12387. */
  12388. constructor(
  12389. /**
  12390. * the particle system to be used by the sub emitter
  12391. */
  12392. particleSystem: ParticleSystem);
  12393. /**
  12394. * Clones the sub emitter
  12395. * @returns the cloned sub emitter
  12396. */
  12397. clone(): SubEmitter;
  12398. /**
  12399. * Serialize current object to a JSON object
  12400. * @returns the serialized object
  12401. */
  12402. serialize(): any;
  12403. /** @hidden */
  12404. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12405. /**
  12406. * Creates a new SubEmitter from a serialized JSON version
  12407. * @param serializationObject defines the JSON object to read from
  12408. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12409. * @param rootUrl defines the rootUrl for data loading
  12410. * @returns a new SubEmitter
  12411. */
  12412. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12413. /** Release associated resources */
  12414. dispose(): void;
  12415. }
  12416. }
  12417. declare module BABYLON {
  12418. /** @hidden */
  12419. export var imageProcessingDeclaration: {
  12420. name: string;
  12421. shader: string;
  12422. };
  12423. }
  12424. declare module BABYLON {
  12425. /** @hidden */
  12426. export var imageProcessingFunctions: {
  12427. name: string;
  12428. shader: string;
  12429. };
  12430. }
  12431. declare module BABYLON {
  12432. /** @hidden */
  12433. export var particlesPixelShader: {
  12434. name: string;
  12435. shader: string;
  12436. };
  12437. }
  12438. declare module BABYLON {
  12439. /** @hidden */
  12440. export var particlesVertexShader: {
  12441. name: string;
  12442. shader: string;
  12443. };
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * Interface used to define entities containing multiple clip planes
  12448. */
  12449. export interface IClipPlanesHolder {
  12450. /**
  12451. * Gets or sets the active clipplane 1
  12452. */
  12453. clipPlane: Nullable<Plane>;
  12454. /**
  12455. * Gets or sets the active clipplane 2
  12456. */
  12457. clipPlane2: Nullable<Plane>;
  12458. /**
  12459. * Gets or sets the active clipplane 3
  12460. */
  12461. clipPlane3: Nullable<Plane>;
  12462. /**
  12463. * Gets or sets the active clipplane 4
  12464. */
  12465. clipPlane4: Nullable<Plane>;
  12466. /**
  12467. * Gets or sets the active clipplane 5
  12468. */
  12469. clipPlane5: Nullable<Plane>;
  12470. /**
  12471. * Gets or sets the active clipplane 6
  12472. */
  12473. clipPlane6: Nullable<Plane>;
  12474. }
  12475. }
  12476. declare module BABYLON {
  12477. /**
  12478. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12479. *
  12480. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12481. *
  12482. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12483. */
  12484. export class ThinMaterialHelper {
  12485. /**
  12486. * Binds the clip plane information from the holder to the effect.
  12487. * @param effect The effect we are binding the data to
  12488. * @param holder The entity containing the clip plane information
  12489. */
  12490. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12491. }
  12492. }
  12493. declare module BABYLON {
  12494. interface ThinEngine {
  12495. /**
  12496. * Sets alpha constants used by some alpha blending modes
  12497. * @param r defines the red component
  12498. * @param g defines the green component
  12499. * @param b defines the blue component
  12500. * @param a defines the alpha component
  12501. */
  12502. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12503. /**
  12504. * Sets the current alpha mode
  12505. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12506. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12507. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12508. */
  12509. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12510. /**
  12511. * Gets the current alpha mode
  12512. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12513. * @returns the current alpha mode
  12514. */
  12515. getAlphaMode(): number;
  12516. /**
  12517. * Sets the current alpha equation
  12518. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12519. */
  12520. setAlphaEquation(equation: number): void;
  12521. /**
  12522. * Gets the current alpha equation.
  12523. * @returns the current alpha equation
  12524. */
  12525. getAlphaEquation(): number;
  12526. }
  12527. }
  12528. declare module BABYLON {
  12529. /**
  12530. * This represents a particle system in Babylon.
  12531. * 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.
  12532. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12533. * @example https://doc.babylonjs.com/babylon101/particles
  12534. */
  12535. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12536. /**
  12537. * Billboard mode will only apply to Y axis
  12538. */
  12539. static readonly BILLBOARDMODE_Y: number;
  12540. /**
  12541. * Billboard mode will apply to all axes
  12542. */
  12543. static readonly BILLBOARDMODE_ALL: number;
  12544. /**
  12545. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12546. */
  12547. static readonly BILLBOARDMODE_STRETCHED: number;
  12548. /**
  12549. * This function can be defined to provide custom update for active particles.
  12550. * This function will be called instead of regular update (age, position, color, etc.).
  12551. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12552. */
  12553. updateFunction: (particles: Particle[]) => void;
  12554. private _emitterWorldMatrix;
  12555. /**
  12556. * This function can be defined to specify initial direction for every new particle.
  12557. * It by default use the emitterType defined function
  12558. */
  12559. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12560. /**
  12561. * This function can be defined to specify initial position for every new particle.
  12562. * It by default use the emitterType defined function
  12563. */
  12564. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12565. /**
  12566. * @hidden
  12567. */
  12568. _inheritedVelocityOffset: Vector3;
  12569. /**
  12570. * An event triggered when the system is disposed
  12571. */
  12572. onDisposeObservable: Observable<IParticleSystem>;
  12573. private _onDisposeObserver;
  12574. /**
  12575. * Sets a callback that will be triggered when the system is disposed
  12576. */
  12577. set onDispose(callback: () => void);
  12578. private _particles;
  12579. private _epsilon;
  12580. private _capacity;
  12581. private _stockParticles;
  12582. private _newPartsExcess;
  12583. private _vertexData;
  12584. private _vertexBuffer;
  12585. private _vertexBuffers;
  12586. private _spriteBuffer;
  12587. private _indexBuffer;
  12588. private _effect;
  12589. private _customEffect;
  12590. private _cachedDefines;
  12591. private _scaledColorStep;
  12592. private _colorDiff;
  12593. private _scaledDirection;
  12594. private _scaledGravity;
  12595. private _currentRenderId;
  12596. private _alive;
  12597. private _useInstancing;
  12598. private _started;
  12599. private _stopped;
  12600. private _actualFrame;
  12601. private _scaledUpdateSpeed;
  12602. private _vertexBufferSize;
  12603. /** @hidden */
  12604. _currentEmitRateGradient: Nullable<FactorGradient>;
  12605. /** @hidden */
  12606. _currentEmitRate1: number;
  12607. /** @hidden */
  12608. _currentEmitRate2: number;
  12609. /** @hidden */
  12610. _currentStartSizeGradient: Nullable<FactorGradient>;
  12611. /** @hidden */
  12612. _currentStartSize1: number;
  12613. /** @hidden */
  12614. _currentStartSize2: number;
  12615. private readonly _rawTextureWidth;
  12616. private _rampGradientsTexture;
  12617. private _useRampGradients;
  12618. /** Gets or sets a matrix to use to compute projection */
  12619. defaultProjectionMatrix: Matrix;
  12620. /** Gets or sets a matrix to use to compute view */
  12621. defaultViewMatrix: Matrix;
  12622. /** Gets or sets a boolean indicating that ramp gradients must be used
  12623. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12624. */
  12625. get useRampGradients(): boolean;
  12626. set useRampGradients(value: boolean);
  12627. /**
  12628. * 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.
  12629. * 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: [])
  12630. */
  12631. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12632. private _subEmitters;
  12633. /**
  12634. * @hidden
  12635. * If the particle systems emitter should be disposed when the particle system is disposed
  12636. */
  12637. _disposeEmitterOnDispose: boolean;
  12638. /**
  12639. * The current active Sub-systems, this property is used by the root particle system only.
  12640. */
  12641. activeSubSystems: Array<ParticleSystem>;
  12642. /**
  12643. * Specifies if the particles are updated in emitter local space or world space
  12644. */
  12645. isLocal: boolean;
  12646. private _rootParticleSystem;
  12647. /**
  12648. * Gets the current list of active particles
  12649. */
  12650. get particles(): Particle[];
  12651. /**
  12652. * Gets the number of particles active at the same time.
  12653. * @returns The number of active particles.
  12654. */
  12655. getActiveCount(): number;
  12656. /**
  12657. * Returns the string "ParticleSystem"
  12658. * @returns a string containing the class name
  12659. */
  12660. getClassName(): string;
  12661. /**
  12662. * Gets a boolean indicating that the system is stopping
  12663. * @returns true if the system is currently stopping
  12664. */
  12665. isStopping(): boolean;
  12666. /**
  12667. * Gets the custom effect used to render the particles
  12668. * @param blendMode Blend mode for which the effect should be retrieved
  12669. * @returns The effect
  12670. */
  12671. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12672. /**
  12673. * Sets the custom effect used to render the particles
  12674. * @param effect The effect to set
  12675. * @param blendMode Blend mode for which the effect should be set
  12676. */
  12677. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12678. /** @hidden */
  12679. private _onBeforeDrawParticlesObservable;
  12680. /**
  12681. * Observable that will be called just before the particles are drawn
  12682. */
  12683. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12684. /**
  12685. * Gets the name of the particle vertex shader
  12686. */
  12687. get vertexShaderName(): string;
  12688. /**
  12689. * Instantiates a particle system.
  12690. * 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.
  12691. * @param name The name of the particle system
  12692. * @param capacity The max number of particles alive at the same time
  12693. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12694. * @param customEffect a custom effect used to change the way particles are rendered by default
  12695. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12696. * @param epsilon Offset used to render the particles
  12697. */
  12698. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12699. private _addFactorGradient;
  12700. private _removeFactorGradient;
  12701. /**
  12702. * Adds a new life time gradient
  12703. * @param gradient defines the gradient to use (between 0 and 1)
  12704. * @param factor defines the life time factor to affect to the specified gradient
  12705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12706. * @returns the current particle system
  12707. */
  12708. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12709. /**
  12710. * Remove a specific life time gradient
  12711. * @param gradient defines the gradient to remove
  12712. * @returns the current particle system
  12713. */
  12714. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12715. /**
  12716. * Adds a new size gradient
  12717. * @param gradient defines the gradient to use (between 0 and 1)
  12718. * @param factor defines the size factor to affect to the specified gradient
  12719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12720. * @returns the current particle system
  12721. */
  12722. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12723. /**
  12724. * Remove a specific size gradient
  12725. * @param gradient defines the gradient to remove
  12726. * @returns the current particle system
  12727. */
  12728. removeSizeGradient(gradient: number): IParticleSystem;
  12729. /**
  12730. * Adds a new color remap gradient
  12731. * @param gradient defines the gradient to use (between 0 and 1)
  12732. * @param min defines the color remap minimal range
  12733. * @param max defines the color remap maximal range
  12734. * @returns the current particle system
  12735. */
  12736. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12737. /**
  12738. * Remove a specific color remap gradient
  12739. * @param gradient defines the gradient to remove
  12740. * @returns the current particle system
  12741. */
  12742. removeColorRemapGradient(gradient: number): IParticleSystem;
  12743. /**
  12744. * Adds a new alpha remap gradient
  12745. * @param gradient defines the gradient to use (between 0 and 1)
  12746. * @param min defines the alpha remap minimal range
  12747. * @param max defines the alpha remap maximal range
  12748. * @returns the current particle system
  12749. */
  12750. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12751. /**
  12752. * Remove a specific alpha remap gradient
  12753. * @param gradient defines the gradient to remove
  12754. * @returns the current particle system
  12755. */
  12756. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12757. /**
  12758. * Adds a new angular speed gradient
  12759. * @param gradient defines the gradient to use (between 0 and 1)
  12760. * @param factor defines the angular speed to affect to the specified gradient
  12761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12762. * @returns the current particle system
  12763. */
  12764. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12765. /**
  12766. * Remove a specific angular speed gradient
  12767. * @param gradient defines the gradient to remove
  12768. * @returns the current particle system
  12769. */
  12770. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12771. /**
  12772. * Adds a new velocity gradient
  12773. * @param gradient defines the gradient to use (between 0 and 1)
  12774. * @param factor defines the velocity to affect to the specified gradient
  12775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12776. * @returns the current particle system
  12777. */
  12778. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12779. /**
  12780. * Remove a specific velocity gradient
  12781. * @param gradient defines the gradient to remove
  12782. * @returns the current particle system
  12783. */
  12784. removeVelocityGradient(gradient: number): IParticleSystem;
  12785. /**
  12786. * Adds a new limit velocity gradient
  12787. * @param gradient defines the gradient to use (between 0 and 1)
  12788. * @param factor defines the limit velocity value to affect to the specified gradient
  12789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12790. * @returns the current particle system
  12791. */
  12792. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12793. /**
  12794. * Remove a specific limit velocity gradient
  12795. * @param gradient defines the gradient to remove
  12796. * @returns the current particle system
  12797. */
  12798. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12799. /**
  12800. * Adds a new drag gradient
  12801. * @param gradient defines the gradient to use (between 0 and 1)
  12802. * @param factor defines the drag value to affect to the specified gradient
  12803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12804. * @returns the current particle system
  12805. */
  12806. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12807. /**
  12808. * Remove a specific drag gradient
  12809. * @param gradient defines the gradient to remove
  12810. * @returns the current particle system
  12811. */
  12812. removeDragGradient(gradient: number): IParticleSystem;
  12813. /**
  12814. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12815. * @param gradient defines the gradient to use (between 0 and 1)
  12816. * @param factor defines the emit rate value to affect to the specified gradient
  12817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12818. * @returns the current particle system
  12819. */
  12820. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12821. /**
  12822. * Remove a specific emit rate gradient
  12823. * @param gradient defines the gradient to remove
  12824. * @returns the current particle system
  12825. */
  12826. removeEmitRateGradient(gradient: number): IParticleSystem;
  12827. /**
  12828. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12829. * @param gradient defines the gradient to use (between 0 and 1)
  12830. * @param factor defines the start size value to affect to the specified gradient
  12831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12832. * @returns the current particle system
  12833. */
  12834. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12835. /**
  12836. * Remove a specific start size gradient
  12837. * @param gradient defines the gradient to remove
  12838. * @returns the current particle system
  12839. */
  12840. removeStartSizeGradient(gradient: number): IParticleSystem;
  12841. private _createRampGradientTexture;
  12842. /**
  12843. * Gets the current list of ramp gradients.
  12844. * You must use addRampGradient and removeRampGradient to udpate this list
  12845. * @returns the list of ramp gradients
  12846. */
  12847. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12848. /** Force the system to rebuild all gradients that need to be resync */
  12849. forceRefreshGradients(): void;
  12850. private _syncRampGradientTexture;
  12851. /**
  12852. * Adds a new ramp gradient used to remap particle colors
  12853. * @param gradient defines the gradient to use (between 0 and 1)
  12854. * @param color defines the color to affect to the specified gradient
  12855. * @returns the current particle system
  12856. */
  12857. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12858. /**
  12859. * Remove a specific ramp gradient
  12860. * @param gradient defines the gradient to remove
  12861. * @returns the current particle system
  12862. */
  12863. removeRampGradient(gradient: number): ParticleSystem;
  12864. /**
  12865. * Adds a new color gradient
  12866. * @param gradient defines the gradient to use (between 0 and 1)
  12867. * @param color1 defines the color to affect to the specified gradient
  12868. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12869. * @returns this particle system
  12870. */
  12871. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12872. /**
  12873. * Remove a specific color gradient
  12874. * @param gradient defines the gradient to remove
  12875. * @returns this particle system
  12876. */
  12877. removeColorGradient(gradient: number): IParticleSystem;
  12878. private _fetchR;
  12879. protected _reset(): void;
  12880. private _resetEffect;
  12881. private _createVertexBuffers;
  12882. private _createIndexBuffer;
  12883. /**
  12884. * Gets the maximum number of particles active at the same time.
  12885. * @returns The max number of active particles.
  12886. */
  12887. getCapacity(): number;
  12888. /**
  12889. * Gets whether there are still active particles in the system.
  12890. * @returns True if it is alive, otherwise false.
  12891. */
  12892. isAlive(): boolean;
  12893. /**
  12894. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12895. * @returns True if it has been started, otherwise false.
  12896. */
  12897. isStarted(): boolean;
  12898. private _prepareSubEmitterInternalArray;
  12899. /**
  12900. * Starts the particle system and begins to emit
  12901. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12902. */
  12903. start(delay?: number): void;
  12904. /**
  12905. * Stops the particle system.
  12906. * @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.
  12907. */
  12908. stop(stopSubEmitters?: boolean): void;
  12909. /**
  12910. * Remove all active particles
  12911. */
  12912. reset(): void;
  12913. /**
  12914. * @hidden (for internal use only)
  12915. */
  12916. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12917. /**
  12918. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12919. * Its lifetime will start back at 0.
  12920. */
  12921. recycleParticle: (particle: Particle) => void;
  12922. private _stopSubEmitters;
  12923. private _createParticle;
  12924. private _removeFromRoot;
  12925. private _emitFromParticle;
  12926. private _update;
  12927. /** @hidden */
  12928. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12929. /** @hidden */
  12930. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12931. /**
  12932. * Fill the defines array according to the current settings of the particle system
  12933. * @param defines Array to be updated
  12934. * @param blendMode blend mode to take into account when updating the array
  12935. */
  12936. fillDefines(defines: Array<string>, blendMode: number): void;
  12937. /**
  12938. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12939. * @param uniforms Uniforms array to fill
  12940. * @param attributes Attributes array to fill
  12941. * @param samplers Samplers array to fill
  12942. */
  12943. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12944. /** @hidden */
  12945. private _getEffect;
  12946. /**
  12947. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12948. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12949. */
  12950. animate(preWarmOnly?: boolean): void;
  12951. private _appendParticleVertices;
  12952. /**
  12953. * Rebuilds the particle system.
  12954. */
  12955. rebuild(): void;
  12956. /**
  12957. * Is this system ready to be used/rendered
  12958. * @return true if the system is ready
  12959. */
  12960. isReady(): boolean;
  12961. private _render;
  12962. /**
  12963. * Renders the particle system in its current state.
  12964. * @returns the current number of particles
  12965. */
  12966. render(): number;
  12967. /**
  12968. * Disposes the particle system and free the associated resources
  12969. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12970. */
  12971. dispose(disposeTexture?: boolean): void;
  12972. /**
  12973. * Clones the particle system.
  12974. * @param name The name of the cloned object
  12975. * @param newEmitter The new emitter to use
  12976. * @returns the cloned particle system
  12977. */
  12978. clone(name: string, newEmitter: any): ParticleSystem;
  12979. /**
  12980. * Serializes the particle system to a JSON object
  12981. * @param serializeTexture defines if the texture must be serialized as well
  12982. * @returns the JSON object
  12983. */
  12984. serialize(serializeTexture?: boolean): any;
  12985. /** @hidden */
  12986. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12987. /** @hidden */
  12988. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12989. /**
  12990. * Parses a JSON object to create a particle system.
  12991. * @param parsedParticleSystem The JSON object to parse
  12992. * @param sceneOrEngine The scene or the engine to create the particle system in
  12993. * @param rootUrl The root url to use to load external dependencies like texture
  12994. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12995. * @returns the Parsed particle system
  12996. */
  12997. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12998. }
  12999. }
  13000. declare module BABYLON {
  13001. /**
  13002. * A particle represents one of the element emitted by a particle system.
  13003. * This is mainly define by its coordinates, direction, velocity and age.
  13004. */
  13005. export class Particle {
  13006. /**
  13007. * The particle system the particle belongs to.
  13008. */
  13009. particleSystem: ParticleSystem;
  13010. private static _Count;
  13011. /**
  13012. * Unique ID of the particle
  13013. */
  13014. id: number;
  13015. /**
  13016. * The world position of the particle in the scene.
  13017. */
  13018. position: Vector3;
  13019. /**
  13020. * The world direction of the particle in the scene.
  13021. */
  13022. direction: Vector3;
  13023. /**
  13024. * The color of the particle.
  13025. */
  13026. color: Color4;
  13027. /**
  13028. * The color change of the particle per step.
  13029. */
  13030. colorStep: Color4;
  13031. /**
  13032. * Defines how long will the life of the particle be.
  13033. */
  13034. lifeTime: number;
  13035. /**
  13036. * The current age of the particle.
  13037. */
  13038. age: number;
  13039. /**
  13040. * The current size of the particle.
  13041. */
  13042. size: number;
  13043. /**
  13044. * The current scale of the particle.
  13045. */
  13046. scale: Vector2;
  13047. /**
  13048. * The current angle of the particle.
  13049. */
  13050. angle: number;
  13051. /**
  13052. * Defines how fast is the angle changing.
  13053. */
  13054. angularSpeed: number;
  13055. /**
  13056. * Defines the cell index used by the particle to be rendered from a sprite.
  13057. */
  13058. cellIndex: number;
  13059. /**
  13060. * The information required to support color remapping
  13061. */
  13062. remapData: Vector4;
  13063. /** @hidden */
  13064. _randomCellOffset?: number;
  13065. /** @hidden */
  13066. _initialDirection: Nullable<Vector3>;
  13067. /** @hidden */
  13068. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13069. /** @hidden */
  13070. _initialStartSpriteCellID: number;
  13071. /** @hidden */
  13072. _initialEndSpriteCellID: number;
  13073. /** @hidden */
  13074. _currentColorGradient: Nullable<ColorGradient>;
  13075. /** @hidden */
  13076. _currentColor1: Color4;
  13077. /** @hidden */
  13078. _currentColor2: Color4;
  13079. /** @hidden */
  13080. _currentSizeGradient: Nullable<FactorGradient>;
  13081. /** @hidden */
  13082. _currentSize1: number;
  13083. /** @hidden */
  13084. _currentSize2: number;
  13085. /** @hidden */
  13086. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13087. /** @hidden */
  13088. _currentAngularSpeed1: number;
  13089. /** @hidden */
  13090. _currentAngularSpeed2: number;
  13091. /** @hidden */
  13092. _currentVelocityGradient: Nullable<FactorGradient>;
  13093. /** @hidden */
  13094. _currentVelocity1: number;
  13095. /** @hidden */
  13096. _currentVelocity2: number;
  13097. /** @hidden */
  13098. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13099. /** @hidden */
  13100. _currentLimitVelocity1: number;
  13101. /** @hidden */
  13102. _currentLimitVelocity2: number;
  13103. /** @hidden */
  13104. _currentDragGradient: Nullable<FactorGradient>;
  13105. /** @hidden */
  13106. _currentDrag1: number;
  13107. /** @hidden */
  13108. _currentDrag2: number;
  13109. /** @hidden */
  13110. _randomNoiseCoordinates1: Vector3;
  13111. /** @hidden */
  13112. _randomNoiseCoordinates2: Vector3;
  13113. /** @hidden */
  13114. _localPosition?: Vector3;
  13115. /**
  13116. * Creates a new instance Particle
  13117. * @param particleSystem the particle system the particle belongs to
  13118. */
  13119. constructor(
  13120. /**
  13121. * The particle system the particle belongs to.
  13122. */
  13123. particleSystem: ParticleSystem);
  13124. private updateCellInfoFromSystem;
  13125. /**
  13126. * Defines how the sprite cell index is updated for the particle
  13127. */
  13128. updateCellIndex(): void;
  13129. /** @hidden */
  13130. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13131. /** @hidden */
  13132. _inheritParticleInfoToSubEmitters(): void;
  13133. /** @hidden */
  13134. _reset(): void;
  13135. /**
  13136. * Copy the properties of particle to another one.
  13137. * @param other the particle to copy the information to.
  13138. */
  13139. copyTo(other: Particle): void;
  13140. }
  13141. }
  13142. declare module BABYLON {
  13143. /**
  13144. * Particle emitter represents a volume emitting particles.
  13145. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13146. */
  13147. export interface IParticleEmitterType {
  13148. /**
  13149. * Called by the particle System when the direction is computed for the created particle.
  13150. * @param worldMatrix is the world matrix of the particle system
  13151. * @param directionToUpdate is the direction vector to update with the result
  13152. * @param particle is the particle we are computed the direction for
  13153. * @param isLocal defines if the direction should be set in local space
  13154. */
  13155. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13156. /**
  13157. * Called by the particle System when the position is computed for the created particle.
  13158. * @param worldMatrix is the world matrix of the particle system
  13159. * @param positionToUpdate is the position vector to update with the result
  13160. * @param particle is the particle we are computed the position for
  13161. * @param isLocal defines if the position should be set in local space
  13162. */
  13163. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13164. /**
  13165. * Clones the current emitter and returns a copy of it
  13166. * @returns the new emitter
  13167. */
  13168. clone(): IParticleEmitterType;
  13169. /**
  13170. * Called by the GPUParticleSystem to setup the update shader
  13171. * @param effect defines the update shader
  13172. */
  13173. applyToShader(effect: Effect): void;
  13174. /**
  13175. * Returns a string to use to update the GPU particles update shader
  13176. * @returns the effect defines string
  13177. */
  13178. getEffectDefines(): string;
  13179. /**
  13180. * Returns a string representing the class name
  13181. * @returns a string containing the class name
  13182. */
  13183. getClassName(): string;
  13184. /**
  13185. * Serializes the particle system to a JSON object.
  13186. * @returns the JSON object
  13187. */
  13188. serialize(): any;
  13189. /**
  13190. * Parse properties from a JSON object
  13191. * @param serializationObject defines the JSON object
  13192. * @param scene defines the hosting scene
  13193. */
  13194. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13195. }
  13196. }
  13197. declare module BABYLON {
  13198. /**
  13199. * Particle emitter emitting particles from the inside of a box.
  13200. * It emits the particles randomly between 2 given directions.
  13201. */
  13202. export class BoxParticleEmitter implements IParticleEmitterType {
  13203. /**
  13204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13205. */
  13206. direction1: Vector3;
  13207. /**
  13208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13209. */
  13210. direction2: Vector3;
  13211. /**
  13212. * 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.
  13213. */
  13214. minEmitBox: Vector3;
  13215. /**
  13216. * 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.
  13217. */
  13218. maxEmitBox: Vector3;
  13219. /**
  13220. * Creates a new instance BoxParticleEmitter
  13221. */
  13222. constructor();
  13223. /**
  13224. * Called by the particle System when the direction is computed for the created particle.
  13225. * @param worldMatrix is the world matrix of the particle system
  13226. * @param directionToUpdate is the direction vector to update with the result
  13227. * @param particle is the particle we are computed the direction for
  13228. * @param isLocal defines if the direction should be set in local space
  13229. */
  13230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13231. /**
  13232. * Called by the particle System when the position is computed for the created particle.
  13233. * @param worldMatrix is the world matrix of the particle system
  13234. * @param positionToUpdate is the position vector to update with the result
  13235. * @param particle is the particle we are computed the position for
  13236. * @param isLocal defines if the position should be set in local space
  13237. */
  13238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13239. /**
  13240. * Clones the current emitter and returns a copy of it
  13241. * @returns the new emitter
  13242. */
  13243. clone(): BoxParticleEmitter;
  13244. /**
  13245. * Called by the GPUParticleSystem to setup the update shader
  13246. * @param effect defines the update shader
  13247. */
  13248. applyToShader(effect: Effect): void;
  13249. /**
  13250. * Returns a string to use to update the GPU particles update shader
  13251. * @returns a string containng the defines string
  13252. */
  13253. getEffectDefines(): string;
  13254. /**
  13255. * Returns the string "BoxParticleEmitter"
  13256. * @returns a string containing the class name
  13257. */
  13258. getClassName(): string;
  13259. /**
  13260. * Serializes the particle system to a JSON object.
  13261. * @returns the JSON object
  13262. */
  13263. serialize(): any;
  13264. /**
  13265. * Parse properties from a JSON object
  13266. * @param serializationObject defines the JSON object
  13267. */
  13268. parse(serializationObject: any): void;
  13269. }
  13270. }
  13271. declare module BABYLON {
  13272. /**
  13273. * Particle emitter emitting particles from the inside of a cone.
  13274. * It emits the particles alongside the cone volume from the base to the particle.
  13275. * The emission direction might be randomized.
  13276. */
  13277. export class ConeParticleEmitter implements IParticleEmitterType {
  13278. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13279. directionRandomizer: number;
  13280. private _radius;
  13281. private _angle;
  13282. private _height;
  13283. /**
  13284. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13285. */
  13286. radiusRange: number;
  13287. /**
  13288. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13289. */
  13290. heightRange: number;
  13291. /**
  13292. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13293. */
  13294. emitFromSpawnPointOnly: boolean;
  13295. /**
  13296. * Gets or sets the radius of the emission cone
  13297. */
  13298. get radius(): number;
  13299. set radius(value: number);
  13300. /**
  13301. * Gets or sets the angle of the emission cone
  13302. */
  13303. get angle(): number;
  13304. set angle(value: number);
  13305. private _buildHeight;
  13306. /**
  13307. * Creates a new instance ConeParticleEmitter
  13308. * @param radius the radius of the emission cone (1 by default)
  13309. * @param angle the cone base angle (PI by default)
  13310. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13311. */
  13312. constructor(radius?: number, angle?: number,
  13313. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13314. directionRandomizer?: number);
  13315. /**
  13316. * Called by the particle System when the direction is computed for the created particle.
  13317. * @param worldMatrix is the world matrix of the particle system
  13318. * @param directionToUpdate is the direction vector to update with the result
  13319. * @param particle is the particle we are computed the direction for
  13320. * @param isLocal defines if the direction should be set in local space
  13321. */
  13322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13323. /**
  13324. * Called by the particle System when the position is computed for the created particle.
  13325. * @param worldMatrix is the world matrix of the particle system
  13326. * @param positionToUpdate is the position vector to update with the result
  13327. * @param particle is the particle we are computed the position for
  13328. * @param isLocal defines if the position should be set in local space
  13329. */
  13330. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13331. /**
  13332. * Clones the current emitter and returns a copy of it
  13333. * @returns the new emitter
  13334. */
  13335. clone(): ConeParticleEmitter;
  13336. /**
  13337. * Called by the GPUParticleSystem to setup the update shader
  13338. * @param effect defines the update shader
  13339. */
  13340. applyToShader(effect: Effect): void;
  13341. /**
  13342. * Returns a string to use to update the GPU particles update shader
  13343. * @returns a string containng the defines string
  13344. */
  13345. getEffectDefines(): string;
  13346. /**
  13347. * Returns the string "ConeParticleEmitter"
  13348. * @returns a string containing the class name
  13349. */
  13350. getClassName(): string;
  13351. /**
  13352. * Serializes the particle system to a JSON object.
  13353. * @returns the JSON object
  13354. */
  13355. serialize(): any;
  13356. /**
  13357. * Parse properties from a JSON object
  13358. * @param serializationObject defines the JSON object
  13359. */
  13360. parse(serializationObject: any): void;
  13361. }
  13362. }
  13363. declare module BABYLON {
  13364. /**
  13365. * Particle emitter emitting particles from the inside of a cylinder.
  13366. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13367. */
  13368. export class CylinderParticleEmitter implements IParticleEmitterType {
  13369. /**
  13370. * The radius of the emission cylinder.
  13371. */
  13372. radius: number;
  13373. /**
  13374. * The height of the emission cylinder.
  13375. */
  13376. height: number;
  13377. /**
  13378. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13379. */
  13380. radiusRange: number;
  13381. /**
  13382. * How much to randomize the particle direction [0-1].
  13383. */
  13384. directionRandomizer: number;
  13385. /**
  13386. * Creates a new instance CylinderParticleEmitter
  13387. * @param radius the radius of the emission cylinder (1 by default)
  13388. * @param height the height of the emission cylinder (1 by default)
  13389. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13390. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13391. */
  13392. constructor(
  13393. /**
  13394. * The radius of the emission cylinder.
  13395. */
  13396. radius?: number,
  13397. /**
  13398. * The height of the emission cylinder.
  13399. */
  13400. height?: number,
  13401. /**
  13402. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13403. */
  13404. radiusRange?: number,
  13405. /**
  13406. * How much to randomize the particle direction [0-1].
  13407. */
  13408. directionRandomizer?: number);
  13409. /**
  13410. * Called by the particle System when the direction is computed for the created particle.
  13411. * @param worldMatrix is the world matrix of the particle system
  13412. * @param directionToUpdate is the direction vector to update with the result
  13413. * @param particle is the particle we are computed the direction for
  13414. * @param isLocal defines if the direction should be set in local space
  13415. */
  13416. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13417. /**
  13418. * Called by the particle System when the position is computed for the created particle.
  13419. * @param worldMatrix is the world matrix of the particle system
  13420. * @param positionToUpdate is the position vector to update with the result
  13421. * @param particle is the particle we are computed the position for
  13422. * @param isLocal defines if the position should be set in local space
  13423. */
  13424. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13425. /**
  13426. * Clones the current emitter and returns a copy of it
  13427. * @returns the new emitter
  13428. */
  13429. clone(): CylinderParticleEmitter;
  13430. /**
  13431. * Called by the GPUParticleSystem to setup the update shader
  13432. * @param effect defines the update shader
  13433. */
  13434. applyToShader(effect: Effect): void;
  13435. /**
  13436. * Returns a string to use to update the GPU particles update shader
  13437. * @returns a string containng the defines string
  13438. */
  13439. getEffectDefines(): string;
  13440. /**
  13441. * Returns the string "CylinderParticleEmitter"
  13442. * @returns a string containing the class name
  13443. */
  13444. getClassName(): string;
  13445. /**
  13446. * Serializes the particle system to a JSON object.
  13447. * @returns the JSON object
  13448. */
  13449. serialize(): any;
  13450. /**
  13451. * Parse properties from a JSON object
  13452. * @param serializationObject defines the JSON object
  13453. */
  13454. parse(serializationObject: any): void;
  13455. }
  13456. /**
  13457. * Particle emitter emitting particles from the inside of a cylinder.
  13458. * It emits the particles randomly between two vectors.
  13459. */
  13460. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13461. /**
  13462. * The min limit of the emission direction.
  13463. */
  13464. direction1: Vector3;
  13465. /**
  13466. * The max limit of the emission direction.
  13467. */
  13468. direction2: Vector3;
  13469. /**
  13470. * Creates a new instance CylinderDirectedParticleEmitter
  13471. * @param radius the radius of the emission cylinder (1 by default)
  13472. * @param height the height of the emission cylinder (1 by default)
  13473. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13474. * @param direction1 the min limit of the emission direction (up vector by default)
  13475. * @param direction2 the max limit of the emission direction (up vector by default)
  13476. */
  13477. constructor(radius?: number, height?: number, radiusRange?: number,
  13478. /**
  13479. * The min limit of the emission direction.
  13480. */
  13481. direction1?: Vector3,
  13482. /**
  13483. * The max limit of the emission direction.
  13484. */
  13485. direction2?: Vector3);
  13486. /**
  13487. * Called by the particle System when the direction is computed for the created particle.
  13488. * @param worldMatrix is the world matrix of the particle system
  13489. * @param directionToUpdate is the direction vector to update with the result
  13490. * @param particle is the particle we are computed the direction for
  13491. */
  13492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13493. /**
  13494. * Clones the current emitter and returns a copy of it
  13495. * @returns the new emitter
  13496. */
  13497. clone(): CylinderDirectedParticleEmitter;
  13498. /**
  13499. * Called by the GPUParticleSystem to setup the update shader
  13500. * @param effect defines the update shader
  13501. */
  13502. applyToShader(effect: Effect): void;
  13503. /**
  13504. * Returns a string to use to update the GPU particles update shader
  13505. * @returns a string containng the defines string
  13506. */
  13507. getEffectDefines(): string;
  13508. /**
  13509. * Returns the string "CylinderDirectedParticleEmitter"
  13510. * @returns a string containing the class name
  13511. */
  13512. getClassName(): string;
  13513. /**
  13514. * Serializes the particle system to a JSON object.
  13515. * @returns the JSON object
  13516. */
  13517. serialize(): any;
  13518. /**
  13519. * Parse properties from a JSON object
  13520. * @param serializationObject defines the JSON object
  13521. */
  13522. parse(serializationObject: any): void;
  13523. }
  13524. }
  13525. declare module BABYLON {
  13526. /**
  13527. * Particle emitter emitting particles from the inside of a hemisphere.
  13528. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13529. */
  13530. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13531. /**
  13532. * The radius of the emission hemisphere.
  13533. */
  13534. radius: number;
  13535. /**
  13536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13537. */
  13538. radiusRange: number;
  13539. /**
  13540. * How much to randomize the particle direction [0-1].
  13541. */
  13542. directionRandomizer: number;
  13543. /**
  13544. * Creates a new instance HemisphericParticleEmitter
  13545. * @param radius the radius of the emission hemisphere (1 by default)
  13546. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13547. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13548. */
  13549. constructor(
  13550. /**
  13551. * The radius of the emission hemisphere.
  13552. */
  13553. radius?: number,
  13554. /**
  13555. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13556. */
  13557. radiusRange?: number,
  13558. /**
  13559. * How much to randomize the particle direction [0-1].
  13560. */
  13561. directionRandomizer?: number);
  13562. /**
  13563. * Called by the particle System when the direction is computed for the created particle.
  13564. * @param worldMatrix is the world matrix of the particle system
  13565. * @param directionToUpdate is the direction vector to update with the result
  13566. * @param particle is the particle we are computed the direction for
  13567. * @param isLocal defines if the direction should be set in local space
  13568. */
  13569. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13570. /**
  13571. * Called by the particle System when the position is computed for the created particle.
  13572. * @param worldMatrix is the world matrix of the particle system
  13573. * @param positionToUpdate is the position vector to update with the result
  13574. * @param particle is the particle we are computed the position for
  13575. * @param isLocal defines if the position should be set in local space
  13576. */
  13577. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13578. /**
  13579. * Clones the current emitter and returns a copy of it
  13580. * @returns the new emitter
  13581. */
  13582. clone(): HemisphericParticleEmitter;
  13583. /**
  13584. * Called by the GPUParticleSystem to setup the update shader
  13585. * @param effect defines the update shader
  13586. */
  13587. applyToShader(effect: Effect): void;
  13588. /**
  13589. * Returns a string to use to update the GPU particles update shader
  13590. * @returns a string containng the defines string
  13591. */
  13592. getEffectDefines(): string;
  13593. /**
  13594. * Returns the string "HemisphericParticleEmitter"
  13595. * @returns a string containing the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Serializes the particle system to a JSON object.
  13600. * @returns the JSON object
  13601. */
  13602. serialize(): any;
  13603. /**
  13604. * Parse properties from a JSON object
  13605. * @param serializationObject defines the JSON object
  13606. */
  13607. parse(serializationObject: any): void;
  13608. }
  13609. }
  13610. declare module BABYLON {
  13611. /**
  13612. * Particle emitter emitting particles from a point.
  13613. * It emits the particles randomly between 2 given directions.
  13614. */
  13615. export class PointParticleEmitter implements IParticleEmitterType {
  13616. /**
  13617. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13618. */
  13619. direction1: Vector3;
  13620. /**
  13621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13622. */
  13623. direction2: Vector3;
  13624. /**
  13625. * Creates a new instance PointParticleEmitter
  13626. */
  13627. constructor();
  13628. /**
  13629. * Called by the particle System when the direction is computed for the created particle.
  13630. * @param worldMatrix is the world matrix of the particle system
  13631. * @param directionToUpdate is the direction vector to update with the result
  13632. * @param particle is the particle we are computed the direction for
  13633. * @param isLocal defines if the direction should be set in local space
  13634. */
  13635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13636. /**
  13637. * Called by the particle System when the position is computed for the created particle.
  13638. * @param worldMatrix is the world matrix of the particle system
  13639. * @param positionToUpdate is the position vector to update with the result
  13640. * @param particle is the particle we are computed the position for
  13641. * @param isLocal defines if the position should be set in local space
  13642. */
  13643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13644. /**
  13645. * Clones the current emitter and returns a copy of it
  13646. * @returns the new emitter
  13647. */
  13648. clone(): PointParticleEmitter;
  13649. /**
  13650. * Called by the GPUParticleSystem to setup the update shader
  13651. * @param effect defines the update shader
  13652. */
  13653. applyToShader(effect: Effect): void;
  13654. /**
  13655. * Returns a string to use to update the GPU particles update shader
  13656. * @returns a string containng the defines string
  13657. */
  13658. getEffectDefines(): string;
  13659. /**
  13660. * Returns the string "PointParticleEmitter"
  13661. * @returns a string containing the class name
  13662. */
  13663. getClassName(): string;
  13664. /**
  13665. * Serializes the particle system to a JSON object.
  13666. * @returns the JSON object
  13667. */
  13668. serialize(): any;
  13669. /**
  13670. * Parse properties from a JSON object
  13671. * @param serializationObject defines the JSON object
  13672. */
  13673. parse(serializationObject: any): void;
  13674. }
  13675. }
  13676. declare module BABYLON {
  13677. /**
  13678. * Particle emitter emitting particles from the inside of a sphere.
  13679. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13680. */
  13681. export class SphereParticleEmitter implements IParticleEmitterType {
  13682. /**
  13683. * The radius of the emission sphere.
  13684. */
  13685. radius: number;
  13686. /**
  13687. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13688. */
  13689. radiusRange: number;
  13690. /**
  13691. * How much to randomize the particle direction [0-1].
  13692. */
  13693. directionRandomizer: number;
  13694. /**
  13695. * Creates a new instance SphereParticleEmitter
  13696. * @param radius the radius of the emission sphere (1 by default)
  13697. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13698. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13699. */
  13700. constructor(
  13701. /**
  13702. * The radius of the emission sphere.
  13703. */
  13704. radius?: number,
  13705. /**
  13706. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13707. */
  13708. radiusRange?: number,
  13709. /**
  13710. * How much to randomize the particle direction [0-1].
  13711. */
  13712. directionRandomizer?: number);
  13713. /**
  13714. * Called by the particle System when the direction is computed for the created particle.
  13715. * @param worldMatrix is the world matrix of the particle system
  13716. * @param directionToUpdate is the direction vector to update with the result
  13717. * @param particle is the particle we are computed the direction for
  13718. * @param isLocal defines if the direction should be set in local space
  13719. */
  13720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13721. /**
  13722. * Called by the particle System when the position is computed for the created particle.
  13723. * @param worldMatrix is the world matrix of the particle system
  13724. * @param positionToUpdate is the position vector to update with the result
  13725. * @param particle is the particle we are computed the position for
  13726. * @param isLocal defines if the position should be set in local space
  13727. */
  13728. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13729. /**
  13730. * Clones the current emitter and returns a copy of it
  13731. * @returns the new emitter
  13732. */
  13733. clone(): SphereParticleEmitter;
  13734. /**
  13735. * Called by the GPUParticleSystem to setup the update shader
  13736. * @param effect defines the update shader
  13737. */
  13738. applyToShader(effect: Effect): void;
  13739. /**
  13740. * Returns a string to use to update the GPU particles update shader
  13741. * @returns a string containng the defines string
  13742. */
  13743. getEffectDefines(): string;
  13744. /**
  13745. * Returns the string "SphereParticleEmitter"
  13746. * @returns a string containing the class name
  13747. */
  13748. getClassName(): string;
  13749. /**
  13750. * Serializes the particle system to a JSON object.
  13751. * @returns the JSON object
  13752. */
  13753. serialize(): any;
  13754. /**
  13755. * Parse properties from a JSON object
  13756. * @param serializationObject defines the JSON object
  13757. */
  13758. parse(serializationObject: any): void;
  13759. }
  13760. /**
  13761. * Particle emitter emitting particles from the inside of a sphere.
  13762. * It emits the particles randomly between two vectors.
  13763. */
  13764. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13765. /**
  13766. * The min limit of the emission direction.
  13767. */
  13768. direction1: Vector3;
  13769. /**
  13770. * The max limit of the emission direction.
  13771. */
  13772. direction2: Vector3;
  13773. /**
  13774. * Creates a new instance SphereDirectedParticleEmitter
  13775. * @param radius the radius of the emission sphere (1 by default)
  13776. * @param direction1 the min limit of the emission direction (up vector by default)
  13777. * @param direction2 the max limit of the emission direction (up vector by default)
  13778. */
  13779. constructor(radius?: number,
  13780. /**
  13781. * The min limit of the emission direction.
  13782. */
  13783. direction1?: Vector3,
  13784. /**
  13785. * The max limit of the emission direction.
  13786. */
  13787. direction2?: Vector3);
  13788. /**
  13789. * Called by the particle System when the direction is computed for the created particle.
  13790. * @param worldMatrix is the world matrix of the particle system
  13791. * @param directionToUpdate is the direction vector to update with the result
  13792. * @param particle is the particle we are computed the direction for
  13793. */
  13794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13795. /**
  13796. * Clones the current emitter and returns a copy of it
  13797. * @returns the new emitter
  13798. */
  13799. clone(): SphereDirectedParticleEmitter;
  13800. /**
  13801. * Called by the GPUParticleSystem to setup the update shader
  13802. * @param effect defines the update shader
  13803. */
  13804. applyToShader(effect: Effect): void;
  13805. /**
  13806. * Returns a string to use to update the GPU particles update shader
  13807. * @returns a string containng the defines string
  13808. */
  13809. getEffectDefines(): string;
  13810. /**
  13811. * Returns the string "SphereDirectedParticleEmitter"
  13812. * @returns a string containing the class name
  13813. */
  13814. getClassName(): string;
  13815. /**
  13816. * Serializes the particle system to a JSON object.
  13817. * @returns the JSON object
  13818. */
  13819. serialize(): any;
  13820. /**
  13821. * Parse properties from a JSON object
  13822. * @param serializationObject defines the JSON object
  13823. */
  13824. parse(serializationObject: any): void;
  13825. }
  13826. }
  13827. declare module BABYLON {
  13828. /**
  13829. * Particle emitter emitting particles from a custom list of positions.
  13830. */
  13831. export class CustomParticleEmitter implements IParticleEmitterType {
  13832. /**
  13833. * Gets or sets the position generator that will create the inital position of each particle.
  13834. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13835. */
  13836. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13837. /**
  13838. * Gets or sets the destination generator that will create the final destination of each particle.
  13839. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13840. */
  13841. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13842. /**
  13843. * Creates a new instance CustomParticleEmitter
  13844. */
  13845. constructor();
  13846. /**
  13847. * Called by the particle System when the direction is computed for the created particle.
  13848. * @param worldMatrix is the world matrix of the particle system
  13849. * @param directionToUpdate is the direction vector to update with the result
  13850. * @param particle is the particle we are computed the direction for
  13851. * @param isLocal defines if the direction should be set in local space
  13852. */
  13853. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13854. /**
  13855. * Called by the particle System when the position is computed for the created particle.
  13856. * @param worldMatrix is the world matrix of the particle system
  13857. * @param positionToUpdate is the position vector to update with the result
  13858. * @param particle is the particle we are computed the position for
  13859. * @param isLocal defines if the position should be set in local space
  13860. */
  13861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13862. /**
  13863. * Clones the current emitter and returns a copy of it
  13864. * @returns the new emitter
  13865. */
  13866. clone(): CustomParticleEmitter;
  13867. /**
  13868. * Called by the GPUParticleSystem to setup the update shader
  13869. * @param effect defines the update shader
  13870. */
  13871. applyToShader(effect: Effect): void;
  13872. /**
  13873. * Returns a string to use to update the GPU particles update shader
  13874. * @returns a string containng the defines string
  13875. */
  13876. getEffectDefines(): string;
  13877. /**
  13878. * Returns the string "PointParticleEmitter"
  13879. * @returns a string containing the class name
  13880. */
  13881. getClassName(): string;
  13882. /**
  13883. * Serializes the particle system to a JSON object.
  13884. * @returns the JSON object
  13885. */
  13886. serialize(): any;
  13887. /**
  13888. * Parse properties from a JSON object
  13889. * @param serializationObject defines the JSON object
  13890. */
  13891. parse(serializationObject: any): void;
  13892. }
  13893. }
  13894. declare module BABYLON {
  13895. /**
  13896. * Particle emitter emitting particles from the inside of a box.
  13897. * It emits the particles randomly between 2 given directions.
  13898. */
  13899. export class MeshParticleEmitter implements IParticleEmitterType {
  13900. private _indices;
  13901. private _positions;
  13902. private _normals;
  13903. private _storedNormal;
  13904. private _mesh;
  13905. /**
  13906. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13907. */
  13908. direction1: Vector3;
  13909. /**
  13910. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13911. */
  13912. direction2: Vector3;
  13913. /**
  13914. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13915. */
  13916. useMeshNormalsForDirection: boolean;
  13917. /** Defines the mesh to use as source */
  13918. get mesh(): Nullable<AbstractMesh>;
  13919. set mesh(value: Nullable<AbstractMesh>);
  13920. /**
  13921. * Creates a new instance MeshParticleEmitter
  13922. * @param mesh defines the mesh to use as source
  13923. */
  13924. constructor(mesh?: Nullable<AbstractMesh>);
  13925. /**
  13926. * Called by the particle System when the direction is computed for the created particle.
  13927. * @param worldMatrix is the world matrix of the particle system
  13928. * @param directionToUpdate is the direction vector to update with the result
  13929. * @param particle is the particle we are computed the direction for
  13930. * @param isLocal defines if the direction should be set in local space
  13931. */
  13932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13933. /**
  13934. * Called by the particle System when the position is computed for the created particle.
  13935. * @param worldMatrix is the world matrix of the particle system
  13936. * @param positionToUpdate is the position vector to update with the result
  13937. * @param particle is the particle we are computed the position for
  13938. * @param isLocal defines if the position should be set in local space
  13939. */
  13940. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13941. /**
  13942. * Clones the current emitter and returns a copy of it
  13943. * @returns the new emitter
  13944. */
  13945. clone(): MeshParticleEmitter;
  13946. /**
  13947. * Called by the GPUParticleSystem to setup the update shader
  13948. * @param effect defines the update shader
  13949. */
  13950. applyToShader(effect: Effect): void;
  13951. /**
  13952. * Returns a string to use to update the GPU particles update shader
  13953. * @returns a string containng the defines string
  13954. */
  13955. getEffectDefines(): string;
  13956. /**
  13957. * Returns the string "BoxParticleEmitter"
  13958. * @returns a string containing the class name
  13959. */
  13960. getClassName(): string;
  13961. /**
  13962. * Serializes the particle system to a JSON object.
  13963. * @returns the JSON object
  13964. */
  13965. serialize(): any;
  13966. /**
  13967. * Parse properties from a JSON object
  13968. * @param serializationObject defines the JSON object
  13969. * @param scene defines the hosting scene
  13970. */
  13971. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13972. }
  13973. }
  13974. declare module BABYLON {
  13975. /**
  13976. * Interface representing a particle system in Babylon.js.
  13977. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13978. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13979. */
  13980. export interface IParticleSystem {
  13981. /**
  13982. * List of animations used by the particle system.
  13983. */
  13984. animations: Animation[];
  13985. /**
  13986. * The id of the Particle system.
  13987. */
  13988. id: string;
  13989. /**
  13990. * The name of the Particle system.
  13991. */
  13992. name: string;
  13993. /**
  13994. * The emitter represents the Mesh or position we are attaching the particle system to.
  13995. */
  13996. emitter: Nullable<AbstractMesh | Vector3>;
  13997. /**
  13998. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13999. */
  14000. isBillboardBased: boolean;
  14001. /**
  14002. * The rendering group used by the Particle system to chose when to render.
  14003. */
  14004. renderingGroupId: number;
  14005. /**
  14006. * The layer mask we are rendering the particles through.
  14007. */
  14008. layerMask: number;
  14009. /**
  14010. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14011. */
  14012. updateSpeed: number;
  14013. /**
  14014. * The amount of time the particle system is running (depends of the overall update speed).
  14015. */
  14016. targetStopDuration: number;
  14017. /**
  14018. * The texture used to render each particle. (this can be a spritesheet)
  14019. */
  14020. particleTexture: Nullable<BaseTexture>;
  14021. /**
  14022. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14023. */
  14024. blendMode: number;
  14025. /**
  14026. * Minimum life time of emitting particles.
  14027. */
  14028. minLifeTime: number;
  14029. /**
  14030. * Maximum life time of emitting particles.
  14031. */
  14032. maxLifeTime: number;
  14033. /**
  14034. * Minimum Size of emitting particles.
  14035. */
  14036. minSize: number;
  14037. /**
  14038. * Maximum Size of emitting particles.
  14039. */
  14040. maxSize: number;
  14041. /**
  14042. * Minimum scale of emitting particles on X axis.
  14043. */
  14044. minScaleX: number;
  14045. /**
  14046. * Maximum scale of emitting particles on X axis.
  14047. */
  14048. maxScaleX: number;
  14049. /**
  14050. * Minimum scale of emitting particles on Y axis.
  14051. */
  14052. minScaleY: number;
  14053. /**
  14054. * Maximum scale of emitting particles on Y axis.
  14055. */
  14056. maxScaleY: number;
  14057. /**
  14058. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14059. */
  14060. color1: Color4;
  14061. /**
  14062. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14063. */
  14064. color2: Color4;
  14065. /**
  14066. * Color the particle will have at the end of its lifetime.
  14067. */
  14068. colorDead: Color4;
  14069. /**
  14070. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14071. */
  14072. emitRate: number;
  14073. /**
  14074. * You can use gravity if you want to give an orientation to your particles.
  14075. */
  14076. gravity: Vector3;
  14077. /**
  14078. * Minimum power of emitting particles.
  14079. */
  14080. minEmitPower: number;
  14081. /**
  14082. * Maximum power of emitting particles.
  14083. */
  14084. maxEmitPower: number;
  14085. /**
  14086. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14087. */
  14088. minAngularSpeed: number;
  14089. /**
  14090. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14091. */
  14092. maxAngularSpeed: number;
  14093. /**
  14094. * Gets or sets the minimal initial rotation in radians.
  14095. */
  14096. minInitialRotation: number;
  14097. /**
  14098. * Gets or sets the maximal initial rotation in radians.
  14099. */
  14100. maxInitialRotation: number;
  14101. /**
  14102. * The particle emitter type defines the emitter used by the particle system.
  14103. * It can be for example box, sphere, or cone...
  14104. */
  14105. particleEmitterType: Nullable<IParticleEmitterType>;
  14106. /**
  14107. * Defines the delay in milliseconds before starting the system (0 by default)
  14108. */
  14109. startDelay: number;
  14110. /**
  14111. * 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
  14112. */
  14113. preWarmCycles: number;
  14114. /**
  14115. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14116. */
  14117. preWarmStepOffset: number;
  14118. /**
  14119. * 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)
  14120. */
  14121. spriteCellChangeSpeed: number;
  14122. /**
  14123. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14124. */
  14125. startSpriteCellID: number;
  14126. /**
  14127. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14128. */
  14129. endSpriteCellID: number;
  14130. /**
  14131. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14132. */
  14133. spriteCellWidth: number;
  14134. /**
  14135. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14136. */
  14137. spriteCellHeight: number;
  14138. /**
  14139. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14140. */
  14141. spriteRandomStartCell: boolean;
  14142. /**
  14143. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14144. */
  14145. isAnimationSheetEnabled: boolean;
  14146. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14147. translationPivot: Vector2;
  14148. /**
  14149. * Gets or sets a texture used to add random noise to particle positions
  14150. */
  14151. noiseTexture: Nullable<BaseTexture>;
  14152. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14153. noiseStrength: Vector3;
  14154. /**
  14155. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14156. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14157. */
  14158. billboardMode: number;
  14159. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14160. limitVelocityDamping: number;
  14161. /**
  14162. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14163. */
  14164. beginAnimationOnStart: boolean;
  14165. /**
  14166. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14167. */
  14168. beginAnimationFrom: number;
  14169. /**
  14170. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14171. */
  14172. beginAnimationTo: number;
  14173. /**
  14174. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14175. */
  14176. beginAnimationLoop: boolean;
  14177. /**
  14178. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14179. */
  14180. disposeOnStop: boolean;
  14181. /**
  14182. * Specifies if the particles are updated in emitter local space or world space
  14183. */
  14184. isLocal: boolean;
  14185. /** Snippet ID if the particle system was created from the snippet server */
  14186. snippetId: string;
  14187. /** Gets or sets a matrix to use to compute projection */
  14188. defaultProjectionMatrix: Matrix;
  14189. /**
  14190. * Gets the maximum number of particles active at the same time.
  14191. * @returns The max number of active particles.
  14192. */
  14193. getCapacity(): number;
  14194. /**
  14195. * Gets the number of particles active at the same time.
  14196. * @returns The number of active particles.
  14197. */
  14198. getActiveCount(): number;
  14199. /**
  14200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14201. * @returns True if it has been started, otherwise false.
  14202. */
  14203. isStarted(): boolean;
  14204. /**
  14205. * Animates the particle system for this frame.
  14206. */
  14207. animate(): void;
  14208. /**
  14209. * Renders the particle system in its current state.
  14210. * @returns the current number of particles
  14211. */
  14212. render(): number;
  14213. /**
  14214. * Dispose the particle system and frees its associated resources.
  14215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14216. */
  14217. dispose(disposeTexture?: boolean): void;
  14218. /**
  14219. * An event triggered when the system is disposed
  14220. */
  14221. onDisposeObservable: Observable<IParticleSystem>;
  14222. /**
  14223. * Clones the particle system.
  14224. * @param name The name of the cloned object
  14225. * @param newEmitter The new emitter to use
  14226. * @returns the cloned particle system
  14227. */
  14228. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14229. /**
  14230. * Serializes the particle system to a JSON object
  14231. * @param serializeTexture defines if the texture must be serialized as well
  14232. * @returns the JSON object
  14233. */
  14234. serialize(serializeTexture: boolean): any;
  14235. /**
  14236. * Rebuild the particle system
  14237. */
  14238. rebuild(): void;
  14239. /** Force the system to rebuild all gradients that need to be resync */
  14240. forceRefreshGradients(): void;
  14241. /**
  14242. * Starts the particle system and begins to emit
  14243. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14244. */
  14245. start(delay?: number): void;
  14246. /**
  14247. * Stops the particle system.
  14248. */
  14249. stop(): void;
  14250. /**
  14251. * Remove all active particles
  14252. */
  14253. reset(): void;
  14254. /**
  14255. * Gets a boolean indicating that the system is stopping
  14256. * @returns true if the system is currently stopping
  14257. */
  14258. isStopping(): boolean;
  14259. /**
  14260. * Is this system ready to be used/rendered
  14261. * @return true if the system is ready
  14262. */
  14263. isReady(): boolean;
  14264. /**
  14265. * Returns the string "ParticleSystem"
  14266. * @returns a string containing the class name
  14267. */
  14268. getClassName(): string;
  14269. /**
  14270. * Gets the custom effect used to render the particles
  14271. * @param blendMode Blend mode for which the effect should be retrieved
  14272. * @returns The effect
  14273. */
  14274. getCustomEffect(blendMode: number): Nullable<Effect>;
  14275. /**
  14276. * Sets the custom effect used to render the particles
  14277. * @param effect The effect to set
  14278. * @param blendMode Blend mode for which the effect should be set
  14279. */
  14280. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14281. /**
  14282. * Fill the defines array according to the current settings of the particle system
  14283. * @param defines Array to be updated
  14284. * @param blendMode blend mode to take into account when updating the array
  14285. */
  14286. fillDefines(defines: Array<string>, blendMode: number): void;
  14287. /**
  14288. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14289. * @param uniforms Uniforms array to fill
  14290. * @param attributes Attributes array to fill
  14291. * @param samplers Samplers array to fill
  14292. */
  14293. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14294. /**
  14295. * Observable that will be called just before the particles are drawn
  14296. */
  14297. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14298. /**
  14299. * Gets the name of the particle vertex shader
  14300. */
  14301. vertexShaderName: string;
  14302. /**
  14303. * Adds a new color gradient
  14304. * @param gradient defines the gradient to use (between 0 and 1)
  14305. * @param color1 defines the color to affect to the specified gradient
  14306. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14307. * @returns the current particle system
  14308. */
  14309. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14310. /**
  14311. * Remove a specific color gradient
  14312. * @param gradient defines the gradient to remove
  14313. * @returns the current particle system
  14314. */
  14315. removeColorGradient(gradient: number): IParticleSystem;
  14316. /**
  14317. * Adds a new size gradient
  14318. * @param gradient defines the gradient to use (between 0 and 1)
  14319. * @param factor defines the size factor to affect to the specified gradient
  14320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14321. * @returns the current particle system
  14322. */
  14323. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14324. /**
  14325. * Remove a specific size gradient
  14326. * @param gradient defines the gradient to remove
  14327. * @returns the current particle system
  14328. */
  14329. removeSizeGradient(gradient: number): IParticleSystem;
  14330. /**
  14331. * Gets the current list of color gradients.
  14332. * You must use addColorGradient and removeColorGradient to udpate this list
  14333. * @returns the list of color gradients
  14334. */
  14335. getColorGradients(): Nullable<Array<ColorGradient>>;
  14336. /**
  14337. * Gets the current list of size gradients.
  14338. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14339. * @returns the list of size gradients
  14340. */
  14341. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14342. /**
  14343. * Gets the current list of angular speed gradients.
  14344. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14345. * @returns the list of angular speed gradients
  14346. */
  14347. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14348. /**
  14349. * Adds a new angular speed gradient
  14350. * @param gradient defines the gradient to use (between 0 and 1)
  14351. * @param factor defines the angular speed to affect to the specified gradient
  14352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14353. * @returns the current particle system
  14354. */
  14355. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14356. /**
  14357. * Remove a specific angular speed gradient
  14358. * @param gradient defines the gradient to remove
  14359. * @returns the current particle system
  14360. */
  14361. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14362. /**
  14363. * Gets the current list of velocity gradients.
  14364. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14365. * @returns the list of velocity gradients
  14366. */
  14367. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14368. /**
  14369. * Adds a new velocity gradient
  14370. * @param gradient defines the gradient to use (between 0 and 1)
  14371. * @param factor defines the velocity to affect to the specified gradient
  14372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14373. * @returns the current particle system
  14374. */
  14375. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14376. /**
  14377. * Remove a specific velocity gradient
  14378. * @param gradient defines the gradient to remove
  14379. * @returns the current particle system
  14380. */
  14381. removeVelocityGradient(gradient: number): IParticleSystem;
  14382. /**
  14383. * Gets the current list of limit velocity gradients.
  14384. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14385. * @returns the list of limit velocity gradients
  14386. */
  14387. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Adds a new limit velocity gradient
  14390. * @param gradient defines the gradient to use (between 0 and 1)
  14391. * @param factor defines the limit velocity to affect to the specified gradient
  14392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14393. * @returns the current particle system
  14394. */
  14395. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14396. /**
  14397. * Remove a specific limit velocity gradient
  14398. * @param gradient defines the gradient to remove
  14399. * @returns the current particle system
  14400. */
  14401. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14402. /**
  14403. * Adds a new drag gradient
  14404. * @param gradient defines the gradient to use (between 0 and 1)
  14405. * @param factor defines the drag to affect to the specified gradient
  14406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14407. * @returns the current particle system
  14408. */
  14409. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14410. /**
  14411. * Remove a specific drag gradient
  14412. * @param gradient defines the gradient to remove
  14413. * @returns the current particle system
  14414. */
  14415. removeDragGradient(gradient: number): IParticleSystem;
  14416. /**
  14417. * Gets the current list of drag gradients.
  14418. * You must use addDragGradient and removeDragGradient to udpate this list
  14419. * @returns the list of drag gradients
  14420. */
  14421. getDragGradients(): Nullable<Array<FactorGradient>>;
  14422. /**
  14423. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14424. * @param gradient defines the gradient to use (between 0 and 1)
  14425. * @param factor defines the emit rate to affect to the specified gradient
  14426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14427. * @returns the current particle system
  14428. */
  14429. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14430. /**
  14431. * Remove a specific emit rate gradient
  14432. * @param gradient defines the gradient to remove
  14433. * @returns the current particle system
  14434. */
  14435. removeEmitRateGradient(gradient: number): IParticleSystem;
  14436. /**
  14437. * Gets the current list of emit rate gradients.
  14438. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14439. * @returns the list of emit rate gradients
  14440. */
  14441. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14444. * @param gradient defines the gradient to use (between 0 and 1)
  14445. * @param factor defines the start size to affect to the specified gradient
  14446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14447. * @returns the current particle system
  14448. */
  14449. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14450. /**
  14451. * Remove a specific start size gradient
  14452. * @param gradient defines the gradient to remove
  14453. * @returns the current particle system
  14454. */
  14455. removeStartSizeGradient(gradient: number): IParticleSystem;
  14456. /**
  14457. * Gets the current list of start size gradients.
  14458. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14459. * @returns the list of start size gradients
  14460. */
  14461. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14462. /**
  14463. * Adds a new life time gradient
  14464. * @param gradient defines the gradient to use (between 0 and 1)
  14465. * @param factor defines the life time factor to affect to the specified gradient
  14466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14467. * @returns the current particle system
  14468. */
  14469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14470. /**
  14471. * Remove a specific life time gradient
  14472. * @param gradient defines the gradient to remove
  14473. * @returns the current particle system
  14474. */
  14475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14476. /**
  14477. * Gets the current list of life time gradients.
  14478. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14479. * @returns the list of life time gradients
  14480. */
  14481. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Gets the current list of color gradients.
  14484. * You must use addColorGradient and removeColorGradient to udpate this list
  14485. * @returns the list of color gradients
  14486. */
  14487. getColorGradients(): Nullable<Array<ColorGradient>>;
  14488. /**
  14489. * Adds a new ramp gradient used to remap particle colors
  14490. * @param gradient defines the gradient to use (between 0 and 1)
  14491. * @param color defines the color to affect to the specified gradient
  14492. * @returns the current particle system
  14493. */
  14494. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14495. /**
  14496. * Gets the current list of ramp gradients.
  14497. * You must use addRampGradient and removeRampGradient to udpate this list
  14498. * @returns the list of ramp gradients
  14499. */
  14500. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14501. /** Gets or sets a boolean indicating that ramp gradients must be used
  14502. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14503. */
  14504. useRampGradients: boolean;
  14505. /**
  14506. * Adds a new color remap gradient
  14507. * @param gradient defines the gradient to use (between 0 and 1)
  14508. * @param min defines the color remap minimal range
  14509. * @param max defines the color remap maximal range
  14510. * @returns the current particle system
  14511. */
  14512. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14513. /**
  14514. * Gets the current list of color remap gradients.
  14515. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14516. * @returns the list of color remap gradients
  14517. */
  14518. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14519. /**
  14520. * Adds a new alpha remap gradient
  14521. * @param gradient defines the gradient to use (between 0 and 1)
  14522. * @param min defines the alpha remap minimal range
  14523. * @param max defines the alpha remap maximal range
  14524. * @returns the current particle system
  14525. */
  14526. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14527. /**
  14528. * Gets the current list of alpha remap gradients.
  14529. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14530. * @returns the list of alpha remap gradients
  14531. */
  14532. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14533. /**
  14534. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14537. * @returns the emitter
  14538. */
  14539. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14540. /**
  14541. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14542. * @param radius The radius of the hemisphere to emit from
  14543. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14544. * @returns the emitter
  14545. */
  14546. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14547. /**
  14548. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14549. * @param radius The radius of the sphere to emit from
  14550. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14551. * @returns the emitter
  14552. */
  14553. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14554. /**
  14555. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14556. * @param radius The radius of the sphere to emit from
  14557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14559. * @returns the emitter
  14560. */
  14561. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14562. /**
  14563. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14564. * @param radius The radius of the emission cylinder
  14565. * @param height The height of the emission cylinder
  14566. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14567. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14568. * @returns the emitter
  14569. */
  14570. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14571. /**
  14572. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14573. * @param radius The radius of the cylinder to emit from
  14574. * @param height The height of the emission cylinder
  14575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14578. * @returns the emitter
  14579. */
  14580. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14581. /**
  14582. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14583. * @param radius The radius of the cone to emit from
  14584. * @param angle The base angle of the cone
  14585. * @returns the emitter
  14586. */
  14587. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14588. /**
  14589. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14592. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14594. * @returns the emitter
  14595. */
  14596. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14597. /**
  14598. * Get hosting scene
  14599. * @returns the scene
  14600. */
  14601. getScene(): Nullable<Scene>;
  14602. }
  14603. }
  14604. declare module BABYLON {
  14605. /**
  14606. * 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.
  14607. * @see https://doc.babylonjs.com/how_to/transformnode
  14608. */
  14609. export class TransformNode extends Node {
  14610. /**
  14611. * Object will not rotate to face the camera
  14612. */
  14613. static BILLBOARDMODE_NONE: number;
  14614. /**
  14615. * Object will rotate to face the camera but only on the x axis
  14616. */
  14617. static BILLBOARDMODE_X: number;
  14618. /**
  14619. * Object will rotate to face the camera but only on the y axis
  14620. */
  14621. static BILLBOARDMODE_Y: number;
  14622. /**
  14623. * Object will rotate to face the camera but only on the z axis
  14624. */
  14625. static BILLBOARDMODE_Z: number;
  14626. /**
  14627. * Object will rotate to face the camera
  14628. */
  14629. static BILLBOARDMODE_ALL: number;
  14630. /**
  14631. * Object will rotate to face the camera's position instead of orientation
  14632. */
  14633. static BILLBOARDMODE_USE_POSITION: number;
  14634. private static _TmpRotation;
  14635. private static _TmpScaling;
  14636. private static _TmpTranslation;
  14637. private _forward;
  14638. private _forwardInverted;
  14639. private _up;
  14640. private _right;
  14641. private _rightInverted;
  14642. private _position;
  14643. private _rotation;
  14644. private _rotationQuaternion;
  14645. protected _scaling: Vector3;
  14646. protected _isDirty: boolean;
  14647. private _transformToBoneReferal;
  14648. private _isAbsoluteSynced;
  14649. private _billboardMode;
  14650. /**
  14651. * Gets or sets the billboard mode. Default is 0.
  14652. *
  14653. * | Value | Type | Description |
  14654. * | --- | --- | --- |
  14655. * | 0 | BILLBOARDMODE_NONE | |
  14656. * | 1 | BILLBOARDMODE_X | |
  14657. * | 2 | BILLBOARDMODE_Y | |
  14658. * | 4 | BILLBOARDMODE_Z | |
  14659. * | 7 | BILLBOARDMODE_ALL | |
  14660. *
  14661. */
  14662. get billboardMode(): number;
  14663. set billboardMode(value: number);
  14664. private _preserveParentRotationForBillboard;
  14665. /**
  14666. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14667. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14668. */
  14669. get preserveParentRotationForBillboard(): boolean;
  14670. set preserveParentRotationForBillboard(value: boolean);
  14671. /**
  14672. * 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
  14673. */
  14674. scalingDeterminant: number;
  14675. private _infiniteDistance;
  14676. /**
  14677. * Gets or sets the distance of the object to max, often used by skybox
  14678. */
  14679. get infiniteDistance(): boolean;
  14680. set infiniteDistance(value: boolean);
  14681. /**
  14682. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14683. * By default the system will update normals to compensate
  14684. */
  14685. ignoreNonUniformScaling: boolean;
  14686. /**
  14687. * 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
  14688. */
  14689. reIntegrateRotationIntoRotationQuaternion: boolean;
  14690. /** @hidden */
  14691. _poseMatrix: Nullable<Matrix>;
  14692. /** @hidden */
  14693. _localMatrix: Matrix;
  14694. private _usePivotMatrix;
  14695. private _absolutePosition;
  14696. private _absoluteScaling;
  14697. private _absoluteRotationQuaternion;
  14698. private _pivotMatrix;
  14699. private _pivotMatrixInverse;
  14700. protected _postMultiplyPivotMatrix: boolean;
  14701. protected _isWorldMatrixFrozen: boolean;
  14702. /** @hidden */
  14703. _indexInSceneTransformNodesArray: number;
  14704. /**
  14705. * An event triggered after the world matrix is updated
  14706. */
  14707. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14708. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14709. /**
  14710. * Gets a string identifying the name of the class
  14711. * @returns "TransformNode" string
  14712. */
  14713. getClassName(): string;
  14714. /**
  14715. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14716. */
  14717. get position(): Vector3;
  14718. set position(newPosition: Vector3);
  14719. /**
  14720. * 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)).
  14721. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14722. */
  14723. get rotation(): Vector3;
  14724. set rotation(newRotation: Vector3);
  14725. /**
  14726. * 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)).
  14727. */
  14728. get scaling(): Vector3;
  14729. set scaling(newScaling: Vector3);
  14730. /**
  14731. * 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).
  14732. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14733. */
  14734. get rotationQuaternion(): Nullable<Quaternion>;
  14735. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14736. /**
  14737. * The forward direction of that transform in world space.
  14738. */
  14739. get forward(): Vector3;
  14740. /**
  14741. * The up direction of that transform in world space.
  14742. */
  14743. get up(): Vector3;
  14744. /**
  14745. * The right direction of that transform in world space.
  14746. */
  14747. get right(): Vector3;
  14748. /**
  14749. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14750. * @param matrix the matrix to copy the pose from
  14751. * @returns this TransformNode.
  14752. */
  14753. updatePoseMatrix(matrix: Matrix): TransformNode;
  14754. /**
  14755. * Returns the mesh Pose matrix.
  14756. * @returns the pose matrix
  14757. */
  14758. getPoseMatrix(): Matrix;
  14759. /** @hidden */
  14760. _isSynchronized(): boolean;
  14761. /** @hidden */
  14762. _initCache(): void;
  14763. /**
  14764. * Flag the transform node as dirty (Forcing it to update everything)
  14765. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14766. * @returns this transform node
  14767. */
  14768. markAsDirty(property: string): TransformNode;
  14769. /**
  14770. * Returns the current mesh absolute position.
  14771. * Returns a Vector3.
  14772. */
  14773. get absolutePosition(): Vector3;
  14774. /**
  14775. * Returns the current mesh absolute scaling.
  14776. * Returns a Vector3.
  14777. */
  14778. get absoluteScaling(): Vector3;
  14779. /**
  14780. * Returns the current mesh absolute rotation.
  14781. * Returns a Quaternion.
  14782. */
  14783. get absoluteRotationQuaternion(): Quaternion;
  14784. /**
  14785. * Sets a new matrix to apply before all other transformation
  14786. * @param matrix defines the transform matrix
  14787. * @returns the current TransformNode
  14788. */
  14789. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14790. /**
  14791. * Sets a new pivot matrix to the current node
  14792. * @param matrix defines the new pivot matrix to use
  14793. * @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
  14794. * @returns the current TransformNode
  14795. */
  14796. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14797. /**
  14798. * Returns the mesh pivot matrix.
  14799. * Default : Identity.
  14800. * @returns the matrix
  14801. */
  14802. getPivotMatrix(): Matrix;
  14803. /**
  14804. * Instantiate (when possible) or clone that node with its hierarchy
  14805. * @param newParent defines the new parent to use for the instance (or clone)
  14806. * @param options defines options to configure how copy is done
  14807. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14808. * @returns an instance (or a clone) of the current node with its hiearchy
  14809. */
  14810. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14811. doNotInstantiate: boolean;
  14812. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14813. /**
  14814. * Prevents the World matrix to be computed any longer
  14815. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14816. * @returns the TransformNode.
  14817. */
  14818. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14819. /**
  14820. * Allows back the World matrix computation.
  14821. * @returns the TransformNode.
  14822. */
  14823. unfreezeWorldMatrix(): this;
  14824. /**
  14825. * True if the World matrix has been frozen.
  14826. */
  14827. get isWorldMatrixFrozen(): boolean;
  14828. /**
  14829. * Retuns the mesh absolute position in the World.
  14830. * @returns a Vector3.
  14831. */
  14832. getAbsolutePosition(): Vector3;
  14833. /**
  14834. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14835. * @param absolutePosition the absolute position to set
  14836. * @returns the TransformNode.
  14837. */
  14838. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14839. /**
  14840. * Sets the mesh position in its local space.
  14841. * @param vector3 the position to set in localspace
  14842. * @returns the TransformNode.
  14843. */
  14844. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14845. /**
  14846. * Returns the mesh position in the local space from the current World matrix values.
  14847. * @returns a new Vector3.
  14848. */
  14849. getPositionExpressedInLocalSpace(): Vector3;
  14850. /**
  14851. * Translates the mesh along the passed Vector3 in its local space.
  14852. * @param vector3 the distance to translate in localspace
  14853. * @returns the TransformNode.
  14854. */
  14855. locallyTranslate(vector3: Vector3): TransformNode;
  14856. private static _lookAtVectorCache;
  14857. /**
  14858. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14859. * @param targetPoint the position (must be in same space as current mesh) to look at
  14860. * @param yawCor optional yaw (y-axis) correction in radians
  14861. * @param pitchCor optional pitch (x-axis) correction in radians
  14862. * @param rollCor optional roll (z-axis) correction in radians
  14863. * @param space the choosen space of the target
  14864. * @returns the TransformNode.
  14865. */
  14866. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14867. /**
  14868. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14869. * This Vector3 is expressed in the World space.
  14870. * @param localAxis axis to rotate
  14871. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14872. */
  14873. getDirection(localAxis: Vector3): Vector3;
  14874. /**
  14875. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14876. * localAxis is expressed in the mesh local space.
  14877. * result is computed in the Wordl space from the mesh World matrix.
  14878. * @param localAxis axis to rotate
  14879. * @param result the resulting transformnode
  14880. * @returns this TransformNode.
  14881. */
  14882. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14883. /**
  14884. * Sets this transform node rotation to the given local axis.
  14885. * @param localAxis the axis in local space
  14886. * @param yawCor optional yaw (y-axis) correction in radians
  14887. * @param pitchCor optional pitch (x-axis) correction in radians
  14888. * @param rollCor optional roll (z-axis) correction in radians
  14889. * @returns this TransformNode
  14890. */
  14891. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14892. /**
  14893. * Sets a new pivot point to the current node
  14894. * @param point defines the new pivot point to use
  14895. * @param space defines if the point is in world or local space (local by default)
  14896. * @returns the current TransformNode
  14897. */
  14898. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14899. /**
  14900. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14901. * @returns the pivot point
  14902. */
  14903. getPivotPoint(): Vector3;
  14904. /**
  14905. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14906. * @param result the vector3 to store the result
  14907. * @returns this TransformNode.
  14908. */
  14909. getPivotPointToRef(result: Vector3): TransformNode;
  14910. /**
  14911. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14912. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14913. */
  14914. getAbsolutePivotPoint(): Vector3;
  14915. /**
  14916. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14917. * @param result vector3 to store the result
  14918. * @returns this TransformNode.
  14919. */
  14920. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14921. /**
  14922. * Defines the passed node as the parent of the current node.
  14923. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14924. * @see https://doc.babylonjs.com/how_to/parenting
  14925. * @param node the node ot set as the parent
  14926. * @returns this TransformNode.
  14927. */
  14928. setParent(node: Nullable<Node>): TransformNode;
  14929. private _nonUniformScaling;
  14930. /**
  14931. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14932. */
  14933. get nonUniformScaling(): boolean;
  14934. /** @hidden */
  14935. _updateNonUniformScalingState(value: boolean): boolean;
  14936. /**
  14937. * Attach the current TransformNode to another TransformNode associated with a bone
  14938. * @param bone Bone affecting the TransformNode
  14939. * @param affectedTransformNode TransformNode associated with the bone
  14940. * @returns this object
  14941. */
  14942. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14943. /**
  14944. * Detach the transform node if its associated with a bone
  14945. * @returns this object
  14946. */
  14947. detachFromBone(): TransformNode;
  14948. private static _rotationAxisCache;
  14949. /**
  14950. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14951. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14952. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14953. * The passed axis is also normalized.
  14954. * @param axis the axis to rotate around
  14955. * @param amount the amount to rotate in radians
  14956. * @param space Space to rotate in (Default: local)
  14957. * @returns the TransformNode.
  14958. */
  14959. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14960. /**
  14961. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14962. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14963. * The passed axis is also normalized. .
  14964. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14965. * @param point the point to rotate around
  14966. * @param axis the axis to rotate around
  14967. * @param amount the amount to rotate in radians
  14968. * @returns the TransformNode
  14969. */
  14970. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14971. /**
  14972. * Translates the mesh along the axis vector for the passed distance in the given space.
  14973. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14974. * @param axis the axis to translate in
  14975. * @param distance the distance to translate
  14976. * @param space Space to rotate in (Default: local)
  14977. * @returns the TransformNode.
  14978. */
  14979. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14980. /**
  14981. * Adds a rotation step to the mesh current rotation.
  14982. * x, y, z are Euler angles expressed in radians.
  14983. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14984. * This means this rotation is made in the mesh local space only.
  14985. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14986. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14987. * ```javascript
  14988. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14989. * ```
  14990. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14991. * 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.
  14992. * @param x Rotation to add
  14993. * @param y Rotation to add
  14994. * @param z Rotation to add
  14995. * @returns the TransformNode.
  14996. */
  14997. addRotation(x: number, y: number, z: number): TransformNode;
  14998. /**
  14999. * @hidden
  15000. */
  15001. protected _getEffectiveParent(): Nullable<Node>;
  15002. /**
  15003. * Computes the world matrix of the node
  15004. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15005. * @returns the world matrix
  15006. */
  15007. computeWorldMatrix(force?: boolean): Matrix;
  15008. /**
  15009. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15010. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15011. */
  15012. resetLocalMatrix(independentOfChildren?: boolean): void;
  15013. protected _afterComputeWorldMatrix(): void;
  15014. /**
  15015. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15016. * @param func callback function to add
  15017. *
  15018. * @returns the TransformNode.
  15019. */
  15020. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15021. /**
  15022. * Removes a registered callback function.
  15023. * @param func callback function to remove
  15024. * @returns the TransformNode.
  15025. */
  15026. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15027. /**
  15028. * Gets the position of the current mesh in camera space
  15029. * @param camera defines the camera to use
  15030. * @returns a position
  15031. */
  15032. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15033. /**
  15034. * Returns the distance from the mesh to the active camera
  15035. * @param camera defines the camera to use
  15036. * @returns the distance
  15037. */
  15038. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15039. /**
  15040. * Clone the current transform node
  15041. * @param name Name of the new clone
  15042. * @param newParent New parent for the clone
  15043. * @param doNotCloneChildren Do not clone children hierarchy
  15044. * @returns the new transform node
  15045. */
  15046. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15047. /**
  15048. * Serializes the objects information.
  15049. * @param currentSerializationObject defines the object to serialize in
  15050. * @returns the serialized object
  15051. */
  15052. serialize(currentSerializationObject?: any): any;
  15053. /**
  15054. * Returns a new TransformNode object parsed from the source provided.
  15055. * @param parsedTransformNode is the source.
  15056. * @param scene the scne the object belongs to
  15057. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15058. * @returns a new TransformNode object parsed from the source provided.
  15059. */
  15060. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15061. /**
  15062. * Get all child-transformNodes of this node
  15063. * @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
  15064. * @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
  15065. * @returns an array of TransformNode
  15066. */
  15067. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15068. /**
  15069. * Releases resources associated with this transform node.
  15070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15072. */
  15073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15074. /**
  15075. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15076. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15077. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15078. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15079. * @returns the current mesh
  15080. */
  15081. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15082. private _syncAbsoluteScalingAndRotation;
  15083. }
  15084. }
  15085. declare module BABYLON {
  15086. /**
  15087. * Class used to override all child animations of a given target
  15088. */
  15089. export class AnimationPropertiesOverride {
  15090. /**
  15091. * Gets or sets a value indicating if animation blending must be used
  15092. */
  15093. enableBlending: boolean;
  15094. /**
  15095. * Gets or sets the blending speed to use when enableBlending is true
  15096. */
  15097. blendingSpeed: number;
  15098. /**
  15099. * Gets or sets the default loop mode to use
  15100. */
  15101. loopMode: number;
  15102. }
  15103. }
  15104. declare module BABYLON {
  15105. /**
  15106. * Class used to store bone information
  15107. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15108. */
  15109. export class Bone extends Node {
  15110. /**
  15111. * defines the bone name
  15112. */
  15113. name: string;
  15114. private static _tmpVecs;
  15115. private static _tmpQuat;
  15116. private static _tmpMats;
  15117. /**
  15118. * Gets the list of child bones
  15119. */
  15120. children: Bone[];
  15121. /** Gets the animations associated with this bone */
  15122. animations: Animation[];
  15123. /**
  15124. * Gets or sets bone length
  15125. */
  15126. length: number;
  15127. /**
  15128. * @hidden Internal only
  15129. * Set this value to map this bone to a different index in the transform matrices
  15130. * Set this value to -1 to exclude the bone from the transform matrices
  15131. */
  15132. _index: Nullable<number>;
  15133. private _skeleton;
  15134. private _localMatrix;
  15135. private _restPose;
  15136. private _bindPose;
  15137. private _baseMatrix;
  15138. private _absoluteTransform;
  15139. private _invertedAbsoluteTransform;
  15140. private _parent;
  15141. private _scalingDeterminant;
  15142. private _worldTransform;
  15143. private _localScaling;
  15144. private _localRotation;
  15145. private _localPosition;
  15146. private _needToDecompose;
  15147. private _needToCompose;
  15148. /** @hidden */
  15149. _linkedTransformNode: Nullable<TransformNode>;
  15150. /** @hidden */
  15151. _waitingTransformNodeId: Nullable<string>;
  15152. /** @hidden */
  15153. get _matrix(): Matrix;
  15154. /** @hidden */
  15155. set _matrix(value: Matrix);
  15156. /**
  15157. * Create a new bone
  15158. * @param name defines the bone name
  15159. * @param skeleton defines the parent skeleton
  15160. * @param parentBone defines the parent (can be null if the bone is the root)
  15161. * @param localMatrix defines the local matrix
  15162. * @param restPose defines the rest pose matrix
  15163. * @param baseMatrix defines the base matrix
  15164. * @param index defines index of the bone in the hiearchy
  15165. */
  15166. constructor(
  15167. /**
  15168. * defines the bone name
  15169. */
  15170. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15171. /**
  15172. * Gets the current object class name.
  15173. * @return the class name
  15174. */
  15175. getClassName(): string;
  15176. /**
  15177. * Gets the parent skeleton
  15178. * @returns a skeleton
  15179. */
  15180. getSkeleton(): Skeleton;
  15181. /**
  15182. * Gets parent bone
  15183. * @returns a bone or null if the bone is the root of the bone hierarchy
  15184. */
  15185. getParent(): Nullable<Bone>;
  15186. /**
  15187. * Returns an array containing the root bones
  15188. * @returns an array containing the root bones
  15189. */
  15190. getChildren(): Array<Bone>;
  15191. /**
  15192. * Gets the node index in matrix array generated for rendering
  15193. * @returns the node index
  15194. */
  15195. getIndex(): number;
  15196. /**
  15197. * Sets the parent bone
  15198. * @param parent defines the parent (can be null if the bone is the root)
  15199. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15200. */
  15201. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15202. /**
  15203. * Gets the local matrix
  15204. * @returns a matrix
  15205. */
  15206. getLocalMatrix(): Matrix;
  15207. /**
  15208. * Gets the base matrix (initial matrix which remains unchanged)
  15209. * @returns a matrix
  15210. */
  15211. getBaseMatrix(): Matrix;
  15212. /**
  15213. * Gets the rest pose matrix
  15214. * @returns a matrix
  15215. */
  15216. getRestPose(): Matrix;
  15217. /**
  15218. * Sets the rest pose matrix
  15219. * @param matrix the local-space rest pose to set for this bone
  15220. */
  15221. setRestPose(matrix: Matrix): void;
  15222. /**
  15223. * Gets the bind pose matrix
  15224. * @returns the bind pose matrix
  15225. */
  15226. getBindPose(): Matrix;
  15227. /**
  15228. * Sets the bind pose matrix
  15229. * @param matrix the local-space bind pose to set for this bone
  15230. */
  15231. setBindPose(matrix: Matrix): void;
  15232. /**
  15233. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15234. */
  15235. getWorldMatrix(): Matrix;
  15236. /**
  15237. * Sets the local matrix to rest pose matrix
  15238. */
  15239. returnToRest(): void;
  15240. /**
  15241. * Gets the inverse of the absolute transform matrix.
  15242. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15243. * @returns a matrix
  15244. */
  15245. getInvertedAbsoluteTransform(): Matrix;
  15246. /**
  15247. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15248. * @returns a matrix
  15249. */
  15250. getAbsoluteTransform(): Matrix;
  15251. /**
  15252. * Links with the given transform node.
  15253. * The local matrix of this bone is copied from the transform node every frame.
  15254. * @param transformNode defines the transform node to link to
  15255. */
  15256. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15257. /**
  15258. * Gets the node used to drive the bone's transformation
  15259. * @returns a transform node or null
  15260. */
  15261. getTransformNode(): Nullable<TransformNode>;
  15262. /** Gets or sets current position (in local space) */
  15263. get position(): Vector3;
  15264. set position(newPosition: Vector3);
  15265. /** Gets or sets current rotation (in local space) */
  15266. get rotation(): Vector3;
  15267. set rotation(newRotation: Vector3);
  15268. /** Gets or sets current rotation quaternion (in local space) */
  15269. get rotationQuaternion(): Quaternion;
  15270. set rotationQuaternion(newRotation: Quaternion);
  15271. /** Gets or sets current scaling (in local space) */
  15272. get scaling(): Vector3;
  15273. set scaling(newScaling: Vector3);
  15274. /**
  15275. * Gets the animation properties override
  15276. */
  15277. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15278. private _decompose;
  15279. private _compose;
  15280. /**
  15281. * Update the base and local matrices
  15282. * @param matrix defines the new base or local matrix
  15283. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15284. * @param updateLocalMatrix defines if the local matrix should be updated
  15285. */
  15286. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15287. /** @hidden */
  15288. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15289. /**
  15290. * Flag the bone as dirty (Forcing it to update everything)
  15291. */
  15292. markAsDirty(): void;
  15293. /** @hidden */
  15294. _markAsDirtyAndCompose(): void;
  15295. private _markAsDirtyAndDecompose;
  15296. /**
  15297. * Translate the bone in local or world space
  15298. * @param vec The amount to translate the bone
  15299. * @param space The space that the translation is in
  15300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15301. */
  15302. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15303. /**
  15304. * Set the postion of the bone in local or world space
  15305. * @param position The position to set the bone
  15306. * @param space The space that the position is in
  15307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15308. */
  15309. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15310. /**
  15311. * Set the absolute position of the bone (world space)
  15312. * @param position The position to set the bone
  15313. * @param mesh The mesh that this bone is attached to
  15314. */
  15315. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15316. /**
  15317. * Scale the bone on the x, y and z axes (in local space)
  15318. * @param x The amount to scale the bone on the x axis
  15319. * @param y The amount to scale the bone on the y axis
  15320. * @param z The amount to scale the bone on the z axis
  15321. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15322. */
  15323. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15324. /**
  15325. * Set the bone scaling in local space
  15326. * @param scale defines the scaling vector
  15327. */
  15328. setScale(scale: Vector3): void;
  15329. /**
  15330. * Gets the current scaling in local space
  15331. * @returns the current scaling vector
  15332. */
  15333. getScale(): Vector3;
  15334. /**
  15335. * Gets the current scaling in local space and stores it in a target vector
  15336. * @param result defines the target vector
  15337. */
  15338. getScaleToRef(result: Vector3): void;
  15339. /**
  15340. * Set the yaw, pitch, and roll of the bone in local or world space
  15341. * @param yaw The rotation of the bone on the y axis
  15342. * @param pitch The rotation of the bone on the x axis
  15343. * @param roll The rotation of the bone on the z axis
  15344. * @param space The space that the axes of rotation are in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. */
  15347. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15348. /**
  15349. * Add a rotation to the bone on an axis in local or world space
  15350. * @param axis The axis to rotate the bone on
  15351. * @param amount The amount to rotate the bone
  15352. * @param space The space that the axis is in
  15353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15354. */
  15355. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15356. /**
  15357. * Set the rotation of the bone to a particular axis angle in local or world space
  15358. * @param axis The axis to rotate the bone on
  15359. * @param angle The angle that the bone should be rotated to
  15360. * @param space The space that the axis is in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. */
  15363. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15364. /**
  15365. * Set the euler rotation of the bone in local of world space
  15366. * @param rotation The euler rotation that the bone should be set to
  15367. * @param space The space that the rotation is in
  15368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15369. */
  15370. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15371. /**
  15372. * Set the quaternion rotation of the bone in local of world space
  15373. * @param quat The quaternion rotation that the bone should be set to
  15374. * @param space The space that the rotation is in
  15375. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15376. */
  15377. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15378. /**
  15379. * Set the rotation matrix of the bone in local of world space
  15380. * @param rotMat The rotation matrix that the bone should be set to
  15381. * @param space The space that the rotation is in
  15382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15383. */
  15384. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15385. private _rotateWithMatrix;
  15386. private _getNegativeRotationToRef;
  15387. /**
  15388. * Get the position of the bone in local or world space
  15389. * @param space The space that the returned position is in
  15390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15391. * @returns The position of the bone
  15392. */
  15393. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15394. /**
  15395. * Copy the position of the bone to a vector3 in local or world space
  15396. * @param space The space that the returned position is in
  15397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15398. * @param result The vector3 to copy the position to
  15399. */
  15400. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15401. /**
  15402. * Get the absolute position of the bone (world space)
  15403. * @param mesh The mesh that this bone is attached to
  15404. * @returns The absolute position of the bone
  15405. */
  15406. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15407. /**
  15408. * Copy the absolute position of the bone (world space) to the result param
  15409. * @param mesh The mesh that this bone is attached to
  15410. * @param result The vector3 to copy the absolute position to
  15411. */
  15412. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15413. /**
  15414. * Compute the absolute transforms of this bone and its children
  15415. */
  15416. computeAbsoluteTransforms(): void;
  15417. /**
  15418. * Get the world direction from an axis that is in the local space of the bone
  15419. * @param localAxis The local direction that is used to compute the world direction
  15420. * @param mesh The mesh that this bone is attached to
  15421. * @returns The world direction
  15422. */
  15423. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15424. /**
  15425. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15426. * @param localAxis The local direction that is used to compute the world direction
  15427. * @param mesh The mesh that this bone is attached to
  15428. * @param result The vector3 that the world direction will be copied to
  15429. */
  15430. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15431. /**
  15432. * Get the euler rotation of the bone in local or world space
  15433. * @param space The space that the rotation should be in
  15434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15435. * @returns The euler rotation
  15436. */
  15437. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15438. /**
  15439. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15440. * @param space The space that the rotation should be in
  15441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15442. * @param result The vector3 that the rotation should be copied to
  15443. */
  15444. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15445. /**
  15446. * Get the quaternion rotation of the bone in either local or world space
  15447. * @param space The space that the rotation should be in
  15448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15449. * @returns The quaternion rotation
  15450. */
  15451. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15452. /**
  15453. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15454. * @param space The space that the rotation should be in
  15455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15456. * @param result The quaternion that the rotation should be copied to
  15457. */
  15458. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15459. /**
  15460. * Get the rotation matrix of the bone in local or world space
  15461. * @param space The space that the rotation should be in
  15462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15463. * @returns The rotation matrix
  15464. */
  15465. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15466. /**
  15467. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15468. * @param space The space that the rotation should be in
  15469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15470. * @param result The quaternion that the rotation should be copied to
  15471. */
  15472. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15473. /**
  15474. * Get the world position of a point that is in the local space of the bone
  15475. * @param position The local position
  15476. * @param mesh The mesh that this bone is attached to
  15477. * @returns The world position
  15478. */
  15479. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15480. /**
  15481. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15482. * @param position The local position
  15483. * @param mesh The mesh that this bone is attached to
  15484. * @param result The vector3 that the world position should be copied to
  15485. */
  15486. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15487. /**
  15488. * Get the local position of a point that is in world space
  15489. * @param position The world position
  15490. * @param mesh The mesh that this bone is attached to
  15491. * @returns The local position
  15492. */
  15493. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15494. /**
  15495. * Get the local position of a point that is in world space and copy it to the result param
  15496. * @param position The world position
  15497. * @param mesh The mesh that this bone is attached to
  15498. * @param result The vector3 that the local position should be copied to
  15499. */
  15500. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15501. }
  15502. }
  15503. declare module BABYLON {
  15504. /**
  15505. * Defines a runtime animation
  15506. */
  15507. export class RuntimeAnimation {
  15508. private _events;
  15509. /**
  15510. * The current frame of the runtime animation
  15511. */
  15512. private _currentFrame;
  15513. /**
  15514. * The animation used by the runtime animation
  15515. */
  15516. private _animation;
  15517. /**
  15518. * The target of the runtime animation
  15519. */
  15520. private _target;
  15521. /**
  15522. * The initiating animatable
  15523. */
  15524. private _host;
  15525. /**
  15526. * The original value of the runtime animation
  15527. */
  15528. private _originalValue;
  15529. /**
  15530. * The original blend value of the runtime animation
  15531. */
  15532. private _originalBlendValue;
  15533. /**
  15534. * The offsets cache of the runtime animation
  15535. */
  15536. private _offsetsCache;
  15537. /**
  15538. * The high limits cache of the runtime animation
  15539. */
  15540. private _highLimitsCache;
  15541. /**
  15542. * Specifies if the runtime animation has been stopped
  15543. */
  15544. private _stopped;
  15545. /**
  15546. * The blending factor of the runtime animation
  15547. */
  15548. private _blendingFactor;
  15549. /**
  15550. * The BabylonJS scene
  15551. */
  15552. private _scene;
  15553. /**
  15554. * The current value of the runtime animation
  15555. */
  15556. private _currentValue;
  15557. /** @hidden */
  15558. _animationState: _IAnimationState;
  15559. /**
  15560. * The active target of the runtime animation
  15561. */
  15562. private _activeTargets;
  15563. private _currentActiveTarget;
  15564. private _directTarget;
  15565. /**
  15566. * The target path of the runtime animation
  15567. */
  15568. private _targetPath;
  15569. /**
  15570. * The weight of the runtime animation
  15571. */
  15572. private _weight;
  15573. /**
  15574. * The ratio offset of the runtime animation
  15575. */
  15576. private _ratioOffset;
  15577. /**
  15578. * The previous delay of the runtime animation
  15579. */
  15580. private _previousDelay;
  15581. /**
  15582. * The previous ratio of the runtime animation
  15583. */
  15584. private _previousRatio;
  15585. private _enableBlending;
  15586. private _keys;
  15587. private _minFrame;
  15588. private _maxFrame;
  15589. private _minValue;
  15590. private _maxValue;
  15591. private _targetIsArray;
  15592. /**
  15593. * Gets the current frame of the runtime animation
  15594. */
  15595. get currentFrame(): number;
  15596. /**
  15597. * Gets the weight of the runtime animation
  15598. */
  15599. get weight(): number;
  15600. /**
  15601. * Gets the current value of the runtime animation
  15602. */
  15603. get currentValue(): any;
  15604. /**
  15605. * Gets the target path of the runtime animation
  15606. */
  15607. get targetPath(): string;
  15608. /**
  15609. * Gets the actual target of the runtime animation
  15610. */
  15611. get target(): any;
  15612. /**
  15613. * Gets the additive state of the runtime animation
  15614. */
  15615. get isAdditive(): boolean;
  15616. /** @hidden */
  15617. _onLoop: () => void;
  15618. /**
  15619. * Create a new RuntimeAnimation object
  15620. * @param target defines the target of the animation
  15621. * @param animation defines the source animation object
  15622. * @param scene defines the hosting scene
  15623. * @param host defines the initiating Animatable
  15624. */
  15625. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15626. private _preparePath;
  15627. /**
  15628. * Gets the animation from the runtime animation
  15629. */
  15630. get animation(): Animation;
  15631. /**
  15632. * Resets the runtime animation to the beginning
  15633. * @param restoreOriginal defines whether to restore the target property to the original value
  15634. */
  15635. reset(restoreOriginal?: boolean): void;
  15636. /**
  15637. * Specifies if the runtime animation is stopped
  15638. * @returns Boolean specifying if the runtime animation is stopped
  15639. */
  15640. isStopped(): boolean;
  15641. /**
  15642. * Disposes of the runtime animation
  15643. */
  15644. dispose(): void;
  15645. /**
  15646. * Apply the interpolated value to the target
  15647. * @param currentValue defines the value computed by the animation
  15648. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15649. */
  15650. setValue(currentValue: any, weight: number): void;
  15651. private _getOriginalValues;
  15652. private _setValue;
  15653. /**
  15654. * Gets the loop pmode of the runtime animation
  15655. * @returns Loop Mode
  15656. */
  15657. private _getCorrectLoopMode;
  15658. /**
  15659. * Move the current animation to a given frame
  15660. * @param frame defines the frame to move to
  15661. */
  15662. goToFrame(frame: number): void;
  15663. /**
  15664. * @hidden Internal use only
  15665. */
  15666. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15667. /**
  15668. * Execute the current animation
  15669. * @param delay defines the delay to add to the current frame
  15670. * @param from defines the lower bound of the animation range
  15671. * @param to defines the upper bound of the animation range
  15672. * @param loop defines if the current animation must loop
  15673. * @param speedRatio defines the current speed ratio
  15674. * @param weight defines the weight of the animation (default is -1 so no weight)
  15675. * @param onLoop optional callback called when animation loops
  15676. * @returns a boolean indicating if the animation is running
  15677. */
  15678. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15679. }
  15680. }
  15681. declare module BABYLON {
  15682. /**
  15683. * Class used to store an actual running animation
  15684. */
  15685. export class Animatable {
  15686. /** defines the target object */
  15687. target: any;
  15688. /** defines the starting frame number (default is 0) */
  15689. fromFrame: number;
  15690. /** defines the ending frame number (default is 100) */
  15691. toFrame: number;
  15692. /** defines if the animation must loop (default is false) */
  15693. loopAnimation: boolean;
  15694. /** defines a callback to call when animation ends if it is not looping */
  15695. onAnimationEnd?: (() => void) | null | undefined;
  15696. /** defines a callback to call when animation loops */
  15697. onAnimationLoop?: (() => void) | null | undefined;
  15698. /** defines whether the animation should be evaluated additively */
  15699. isAdditive: boolean;
  15700. private _localDelayOffset;
  15701. private _pausedDelay;
  15702. private _runtimeAnimations;
  15703. private _paused;
  15704. private _scene;
  15705. private _speedRatio;
  15706. private _weight;
  15707. private _syncRoot;
  15708. /**
  15709. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15710. * This will only apply for non looping animation (default is true)
  15711. */
  15712. disposeOnEnd: boolean;
  15713. /**
  15714. * Gets a boolean indicating if the animation has started
  15715. */
  15716. animationStarted: boolean;
  15717. /**
  15718. * Observer raised when the animation ends
  15719. */
  15720. onAnimationEndObservable: Observable<Animatable>;
  15721. /**
  15722. * Observer raised when the animation loops
  15723. */
  15724. onAnimationLoopObservable: Observable<Animatable>;
  15725. /**
  15726. * Gets the root Animatable used to synchronize and normalize animations
  15727. */
  15728. get syncRoot(): Nullable<Animatable>;
  15729. /**
  15730. * Gets the current frame of the first RuntimeAnimation
  15731. * Used to synchronize Animatables
  15732. */
  15733. get masterFrame(): number;
  15734. /**
  15735. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15736. */
  15737. get weight(): number;
  15738. set weight(value: number);
  15739. /**
  15740. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15741. */
  15742. get speedRatio(): number;
  15743. set speedRatio(value: number);
  15744. /**
  15745. * Creates a new Animatable
  15746. * @param scene defines the hosting scene
  15747. * @param target defines the target object
  15748. * @param fromFrame defines the starting frame number (default is 0)
  15749. * @param toFrame defines the ending frame number (default is 100)
  15750. * @param loopAnimation defines if the animation must loop (default is false)
  15751. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15752. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15753. * @param animations defines a group of animation to add to the new Animatable
  15754. * @param onAnimationLoop defines a callback to call when animation loops
  15755. * @param isAdditive defines whether the animation should be evaluated additively
  15756. */
  15757. constructor(scene: Scene,
  15758. /** defines the target object */
  15759. target: any,
  15760. /** defines the starting frame number (default is 0) */
  15761. fromFrame?: number,
  15762. /** defines the ending frame number (default is 100) */
  15763. toFrame?: number,
  15764. /** defines if the animation must loop (default is false) */
  15765. loopAnimation?: boolean, speedRatio?: number,
  15766. /** defines a callback to call when animation ends if it is not looping */
  15767. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15768. /** defines a callback to call when animation loops */
  15769. onAnimationLoop?: (() => void) | null | undefined,
  15770. /** defines whether the animation should be evaluated additively */
  15771. isAdditive?: boolean);
  15772. /**
  15773. * Synchronize and normalize current Animatable with a source Animatable
  15774. * This is useful when using animation weights and when animations are not of the same length
  15775. * @param root defines the root Animatable to synchronize with
  15776. * @returns the current Animatable
  15777. */
  15778. syncWith(root: Animatable): Animatable;
  15779. /**
  15780. * Gets the list of runtime animations
  15781. * @returns an array of RuntimeAnimation
  15782. */
  15783. getAnimations(): RuntimeAnimation[];
  15784. /**
  15785. * Adds more animations to the current animatable
  15786. * @param target defines the target of the animations
  15787. * @param animations defines the new animations to add
  15788. */
  15789. appendAnimations(target: any, animations: Animation[]): void;
  15790. /**
  15791. * Gets the source animation for a specific property
  15792. * @param property defines the propertyu to look for
  15793. * @returns null or the source animation for the given property
  15794. */
  15795. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15796. /**
  15797. * Gets the runtime animation for a specific property
  15798. * @param property defines the propertyu to look for
  15799. * @returns null or the runtime animation for the given property
  15800. */
  15801. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15802. /**
  15803. * Resets the animatable to its original state
  15804. */
  15805. reset(): void;
  15806. /**
  15807. * Allows the animatable to blend with current running animations
  15808. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15809. * @param blendingSpeed defines the blending speed to use
  15810. */
  15811. enableBlending(blendingSpeed: number): void;
  15812. /**
  15813. * Disable animation blending
  15814. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15815. */
  15816. disableBlending(): void;
  15817. /**
  15818. * Jump directly to a given frame
  15819. * @param frame defines the frame to jump to
  15820. */
  15821. goToFrame(frame: number): void;
  15822. /**
  15823. * Pause the animation
  15824. */
  15825. pause(): void;
  15826. /**
  15827. * Restart the animation
  15828. */
  15829. restart(): void;
  15830. private _raiseOnAnimationEnd;
  15831. /**
  15832. * Stop and delete the current animation
  15833. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15834. * @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)
  15835. */
  15836. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15837. /**
  15838. * Wait asynchronously for the animation to end
  15839. * @returns a promise which will be fullfilled when the animation ends
  15840. */
  15841. waitAsync(): Promise<Animatable>;
  15842. /** @hidden */
  15843. _animate(delay: number): boolean;
  15844. }
  15845. interface Scene {
  15846. /** @hidden */
  15847. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15848. /** @hidden */
  15849. _processLateAnimationBindingsForMatrices(holder: {
  15850. totalWeight: number;
  15851. totalAdditiveWeight: number;
  15852. animations: RuntimeAnimation[];
  15853. additiveAnimations: RuntimeAnimation[];
  15854. originalValue: Matrix;
  15855. }): any;
  15856. /** @hidden */
  15857. _processLateAnimationBindingsForQuaternions(holder: {
  15858. totalWeight: number;
  15859. totalAdditiveWeight: number;
  15860. animations: RuntimeAnimation[];
  15861. additiveAnimations: RuntimeAnimation[];
  15862. originalValue: Quaternion;
  15863. }, refQuaternion: Quaternion): Quaternion;
  15864. /** @hidden */
  15865. _processLateAnimationBindings(): void;
  15866. /**
  15867. * Will start the animation sequence of a given target
  15868. * @param target defines the target
  15869. * @param from defines from which frame should animation start
  15870. * @param to defines until which frame should animation run.
  15871. * @param weight defines the weight to apply to the animation (1.0 by default)
  15872. * @param loop defines if the animation loops
  15873. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15874. * @param onAnimationEnd defines the function to be executed when the animation ends
  15875. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15876. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15877. * @param onAnimationLoop defines the callback to call when an animation loops
  15878. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15879. * @returns the animatable object created for this animation
  15880. */
  15881. 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;
  15882. /**
  15883. * Will start the animation sequence of a given target
  15884. * @param target defines the target
  15885. * @param from defines from which frame should animation start
  15886. * @param to defines until which frame should animation run.
  15887. * @param loop defines if the animation loops
  15888. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15889. * @param onAnimationEnd defines the function to be executed when the animation ends
  15890. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15891. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15892. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15893. * @param onAnimationLoop defines the callback to call when an animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15895. * @returns the animatable object created for this animation
  15896. */
  15897. 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;
  15898. /**
  15899. * Will start the animation sequence of a given target and its hierarchy
  15900. * @param target defines the target
  15901. * @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.
  15902. * @param from defines from which frame should animation start
  15903. * @param to defines until which frame should animation run.
  15904. * @param loop defines if the animation loops
  15905. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15906. * @param onAnimationEnd defines the function to be executed when the animation ends
  15907. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15908. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15909. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15910. * @param onAnimationLoop defines the callback to call when an animation loops
  15911. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15912. * @returns the list of created animatables
  15913. */
  15914. 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[];
  15915. /**
  15916. * Begin a new animation on a given node
  15917. * @param target defines the target where the animation will take place
  15918. * @param animations defines the list of animations to start
  15919. * @param from defines the initial value
  15920. * @param to defines the final value
  15921. * @param loop defines if you want animation to loop (off by default)
  15922. * @param speedRatio defines the speed ratio to apply to all animations
  15923. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15924. * @param onAnimationLoop defines the callback to call when an animation loops
  15925. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15926. * @returns the list of created animatables
  15927. */
  15928. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15929. /**
  15930. * Begin a new animation on a given node and its hierarchy
  15931. * @param target defines the root node where the animation will take place
  15932. * @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.
  15933. * @param animations defines the list of animations to start
  15934. * @param from defines the initial value
  15935. * @param to defines the final value
  15936. * @param loop defines if you want animation to loop (off by default)
  15937. * @param speedRatio defines the speed ratio to apply to all animations
  15938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15939. * @param onAnimationLoop defines the callback to call when an animation loops
  15940. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15941. * @returns the list of animatables created for all nodes
  15942. */
  15943. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15944. /**
  15945. * Gets the animatable associated with a specific target
  15946. * @param target defines the target of the animatable
  15947. * @returns the required animatable if found
  15948. */
  15949. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15950. /**
  15951. * Gets all animatables associated with a given target
  15952. * @param target defines the target to look animatables for
  15953. * @returns an array of Animatables
  15954. */
  15955. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15956. /**
  15957. * Stops and removes all animations that have been applied to the scene
  15958. */
  15959. stopAllAnimations(): void;
  15960. /**
  15961. * Gets the current delta time used by animation engine
  15962. */
  15963. deltaTime: number;
  15964. }
  15965. interface Bone {
  15966. /**
  15967. * Copy an animation range from another bone
  15968. * @param source defines the source bone
  15969. * @param rangeName defines the range name to copy
  15970. * @param frameOffset defines the frame offset
  15971. * @param rescaleAsRequired defines if rescaling must be applied if required
  15972. * @param skelDimensionsRatio defines the scaling ratio
  15973. * @returns true if operation was successful
  15974. */
  15975. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15976. }
  15977. }
  15978. declare module BABYLON {
  15979. /**
  15980. * Class used to handle skinning animations
  15981. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15982. */
  15983. export class Skeleton implements IAnimatable {
  15984. /** defines the skeleton name */
  15985. name: string;
  15986. /** defines the skeleton Id */
  15987. id: string;
  15988. /**
  15989. * Defines the list of child bones
  15990. */
  15991. bones: Bone[];
  15992. /**
  15993. * Defines an estimate of the dimension of the skeleton at rest
  15994. */
  15995. dimensionsAtRest: Vector3;
  15996. /**
  15997. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15998. */
  15999. needInitialSkinMatrix: boolean;
  16000. /**
  16001. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16002. */
  16003. overrideMesh: Nullable<AbstractMesh>;
  16004. /**
  16005. * Gets the list of animations attached to this skeleton
  16006. */
  16007. animations: Array<Animation>;
  16008. private _scene;
  16009. private _isDirty;
  16010. private _transformMatrices;
  16011. private _transformMatrixTexture;
  16012. private _meshesWithPoseMatrix;
  16013. private _animatables;
  16014. private _identity;
  16015. private _synchronizedWithMesh;
  16016. private _ranges;
  16017. private _lastAbsoluteTransformsUpdateId;
  16018. private _canUseTextureForBones;
  16019. private _uniqueId;
  16020. /** @hidden */
  16021. _numBonesWithLinkedTransformNode: number;
  16022. /** @hidden */
  16023. _hasWaitingData: Nullable<boolean>;
  16024. /**
  16025. * Specifies if the skeleton should be serialized
  16026. */
  16027. doNotSerialize: boolean;
  16028. private _useTextureToStoreBoneMatrices;
  16029. /**
  16030. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16031. * Please note that this option is not available if the hardware does not support it
  16032. */
  16033. get useTextureToStoreBoneMatrices(): boolean;
  16034. set useTextureToStoreBoneMatrices(value: boolean);
  16035. private _animationPropertiesOverride;
  16036. /**
  16037. * Gets or sets the animation properties override
  16038. */
  16039. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16040. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16041. /**
  16042. * List of inspectable custom properties (used by the Inspector)
  16043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16044. */
  16045. inspectableCustomProperties: IInspectable[];
  16046. /**
  16047. * An observable triggered before computing the skeleton's matrices
  16048. */
  16049. onBeforeComputeObservable: Observable<Skeleton>;
  16050. /**
  16051. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16052. */
  16053. get isUsingTextureForMatrices(): boolean;
  16054. /**
  16055. * Gets the unique ID of this skeleton
  16056. */
  16057. get uniqueId(): number;
  16058. /**
  16059. * Creates a new skeleton
  16060. * @param name defines the skeleton name
  16061. * @param id defines the skeleton Id
  16062. * @param scene defines the hosting scene
  16063. */
  16064. constructor(
  16065. /** defines the skeleton name */
  16066. name: string,
  16067. /** defines the skeleton Id */
  16068. id: string, scene: Scene);
  16069. /**
  16070. * Gets the current object class name.
  16071. * @return the class name
  16072. */
  16073. getClassName(): string;
  16074. /**
  16075. * Returns an array containing the root bones
  16076. * @returns an array containing the root bones
  16077. */
  16078. getChildren(): Array<Bone>;
  16079. /**
  16080. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16081. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16082. * @returns a Float32Array containing matrices data
  16083. */
  16084. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16085. /**
  16086. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16087. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16088. * @returns a raw texture containing the data
  16089. */
  16090. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16091. /**
  16092. * Gets the current hosting scene
  16093. * @returns a scene object
  16094. */
  16095. getScene(): Scene;
  16096. /**
  16097. * Gets a string representing the current skeleton data
  16098. * @param fullDetails defines a boolean indicating if we want a verbose version
  16099. * @returns a string representing the current skeleton data
  16100. */
  16101. toString(fullDetails?: boolean): string;
  16102. /**
  16103. * Get bone's index searching by name
  16104. * @param name defines bone's name to search for
  16105. * @return the indice of the bone. Returns -1 if not found
  16106. */
  16107. getBoneIndexByName(name: string): number;
  16108. /**
  16109. * Creater a new animation range
  16110. * @param name defines the name of the range
  16111. * @param from defines the start key
  16112. * @param to defines the end key
  16113. */
  16114. createAnimationRange(name: string, from: number, to: number): void;
  16115. /**
  16116. * Delete a specific animation range
  16117. * @param name defines the name of the range
  16118. * @param deleteFrames defines if frames must be removed as well
  16119. */
  16120. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16121. /**
  16122. * Gets a specific animation range
  16123. * @param name defines the name of the range to look for
  16124. * @returns the requested animation range or null if not found
  16125. */
  16126. getAnimationRange(name: string): Nullable<AnimationRange>;
  16127. /**
  16128. * Gets the list of all animation ranges defined on this skeleton
  16129. * @returns an array
  16130. */
  16131. getAnimationRanges(): Nullable<AnimationRange>[];
  16132. /**
  16133. * Copy animation range from a source skeleton.
  16134. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16135. * @param source defines the source skeleton
  16136. * @param name defines the name of the range to copy
  16137. * @param rescaleAsRequired defines if rescaling must be applied if required
  16138. * @returns true if operation was successful
  16139. */
  16140. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16141. /**
  16142. * Forces the skeleton to go to rest pose
  16143. */
  16144. returnToRest(): void;
  16145. private _getHighestAnimationFrame;
  16146. /**
  16147. * Begin a specific animation range
  16148. * @param name defines the name of the range to start
  16149. * @param loop defines if looping must be turned on (false by default)
  16150. * @param speedRatio defines the speed ratio to apply (1 by default)
  16151. * @param onAnimationEnd defines a callback which will be called when animation will end
  16152. * @returns a new animatable
  16153. */
  16154. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16155. /**
  16156. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16157. * @param skeleton defines the Skeleton containing the animation range to convert
  16158. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16159. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16160. * @returns the original skeleton
  16161. */
  16162. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16163. /** @hidden */
  16164. _markAsDirty(): void;
  16165. /** @hidden */
  16166. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16167. /** @hidden */
  16168. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16169. private _computeTransformMatrices;
  16170. /**
  16171. * Build all resources required to render a skeleton
  16172. */
  16173. prepare(): void;
  16174. /**
  16175. * Gets the list of animatables currently running for this skeleton
  16176. * @returns an array of animatables
  16177. */
  16178. getAnimatables(): IAnimatable[];
  16179. /**
  16180. * Clone the current skeleton
  16181. * @param name defines the name of the new skeleton
  16182. * @param id defines the id of the new skeleton
  16183. * @returns the new skeleton
  16184. */
  16185. clone(name: string, id?: string): Skeleton;
  16186. /**
  16187. * Enable animation blending for this skeleton
  16188. * @param blendingSpeed defines the blending speed to apply
  16189. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16190. */
  16191. enableBlending(blendingSpeed?: number): void;
  16192. /**
  16193. * Releases all resources associated with the current skeleton
  16194. */
  16195. dispose(): void;
  16196. /**
  16197. * Serialize the skeleton in a JSON object
  16198. * @returns a JSON object
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Creates a new skeleton from serialized data
  16203. * @param parsedSkeleton defines the serialized data
  16204. * @param scene defines the hosting scene
  16205. * @returns a new skeleton
  16206. */
  16207. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16208. /**
  16209. * Compute all node absolute transforms
  16210. * @param forceUpdate defines if computation must be done even if cache is up to date
  16211. */
  16212. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16213. /**
  16214. * Gets the root pose matrix
  16215. * @returns a matrix
  16216. */
  16217. getPoseMatrix(): Nullable<Matrix>;
  16218. /**
  16219. * Sorts bones per internal index
  16220. */
  16221. sortBones(): void;
  16222. private _sortBones;
  16223. }
  16224. }
  16225. declare module BABYLON {
  16226. /**
  16227. * Creates an instance based on a source mesh.
  16228. */
  16229. export class InstancedMesh extends AbstractMesh {
  16230. private _sourceMesh;
  16231. private _currentLOD;
  16232. /** @hidden */
  16233. _indexInSourceMeshInstanceArray: number;
  16234. constructor(name: string, source: Mesh);
  16235. /**
  16236. * Returns the string "InstancedMesh".
  16237. */
  16238. getClassName(): string;
  16239. /** Gets the list of lights affecting that mesh */
  16240. get lightSources(): Light[];
  16241. _resyncLightSources(): void;
  16242. _resyncLightSource(light: Light): void;
  16243. _removeLightSource(light: Light, dispose: boolean): void;
  16244. /**
  16245. * If the source mesh receives shadows
  16246. */
  16247. get receiveShadows(): boolean;
  16248. /**
  16249. * The material of the source mesh
  16250. */
  16251. get material(): Nullable<Material>;
  16252. /**
  16253. * Visibility of the source mesh
  16254. */
  16255. get visibility(): number;
  16256. /**
  16257. * Skeleton of the source mesh
  16258. */
  16259. get skeleton(): Nullable<Skeleton>;
  16260. /**
  16261. * Rendering ground id of the source mesh
  16262. */
  16263. get renderingGroupId(): number;
  16264. set renderingGroupId(value: number);
  16265. /**
  16266. * Returns the total number of vertices (integer).
  16267. */
  16268. getTotalVertices(): number;
  16269. /**
  16270. * Returns a positive integer : the total number of indices in this mesh geometry.
  16271. * @returns the numner of indices or zero if the mesh has no geometry.
  16272. */
  16273. getTotalIndices(): number;
  16274. /**
  16275. * The source mesh of the instance
  16276. */
  16277. get sourceMesh(): Mesh;
  16278. /**
  16279. * Creates a new InstancedMesh object from the mesh model.
  16280. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16281. * @param name defines the name of the new instance
  16282. * @returns a new InstancedMesh
  16283. */
  16284. createInstance(name: string): InstancedMesh;
  16285. /**
  16286. * Is this node ready to be used/rendered
  16287. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16288. * @return {boolean} is it ready
  16289. */
  16290. isReady(completeCheck?: boolean): boolean;
  16291. /**
  16292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16293. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16294. * @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.
  16295. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16296. */
  16297. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16298. /**
  16299. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16300. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16301. * The `data` are either a numeric array either a Float32Array.
  16302. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16303. * 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).
  16304. * Note that a new underlying VertexBuffer object is created each call.
  16305. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16306. *
  16307. * Possible `kind` values :
  16308. * - VertexBuffer.PositionKind
  16309. * - VertexBuffer.UVKind
  16310. * - VertexBuffer.UV2Kind
  16311. * - VertexBuffer.UV3Kind
  16312. * - VertexBuffer.UV4Kind
  16313. * - VertexBuffer.UV5Kind
  16314. * - VertexBuffer.UV6Kind
  16315. * - VertexBuffer.ColorKind
  16316. * - VertexBuffer.MatricesIndicesKind
  16317. * - VertexBuffer.MatricesIndicesExtraKind
  16318. * - VertexBuffer.MatricesWeightsKind
  16319. * - VertexBuffer.MatricesWeightsExtraKind
  16320. *
  16321. * Returns the Mesh.
  16322. */
  16323. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16324. /**
  16325. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16326. * If the mesh has no geometry, it is simply returned as it is.
  16327. * The `data` are either a numeric array either a Float32Array.
  16328. * No new underlying VertexBuffer object is created.
  16329. * 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.
  16330. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16331. *
  16332. * Possible `kind` values :
  16333. * - VertexBuffer.PositionKind
  16334. * - VertexBuffer.UVKind
  16335. * - VertexBuffer.UV2Kind
  16336. * - VertexBuffer.UV3Kind
  16337. * - VertexBuffer.UV4Kind
  16338. * - VertexBuffer.UV5Kind
  16339. * - VertexBuffer.UV6Kind
  16340. * - VertexBuffer.ColorKind
  16341. * - VertexBuffer.MatricesIndicesKind
  16342. * - VertexBuffer.MatricesIndicesExtraKind
  16343. * - VertexBuffer.MatricesWeightsKind
  16344. * - VertexBuffer.MatricesWeightsExtraKind
  16345. *
  16346. * Returns the Mesh.
  16347. */
  16348. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16349. /**
  16350. * Sets the mesh indices.
  16351. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16352. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16353. * This method creates a new index buffer each call.
  16354. * Returns the Mesh.
  16355. */
  16356. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16357. /**
  16358. * Boolean : True if the mesh owns the requested kind of data.
  16359. */
  16360. isVerticesDataPresent(kind: string): boolean;
  16361. /**
  16362. * Returns an array of indices (IndicesArray).
  16363. */
  16364. getIndices(): Nullable<IndicesArray>;
  16365. get _positions(): Nullable<Vector3[]>;
  16366. /**
  16367. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16368. * This means the mesh underlying bounding box and sphere are recomputed.
  16369. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16370. * @returns the current mesh
  16371. */
  16372. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16373. /** @hidden */
  16374. _preActivate(): InstancedMesh;
  16375. /** @hidden */
  16376. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16377. /** @hidden */
  16378. _postActivate(): void;
  16379. getWorldMatrix(): Matrix;
  16380. get isAnInstance(): boolean;
  16381. /**
  16382. * Returns the current associated LOD AbstractMesh.
  16383. */
  16384. getLOD(camera: Camera): AbstractMesh;
  16385. /** @hidden */
  16386. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16387. /** @hidden */
  16388. _syncSubMeshes(): InstancedMesh;
  16389. /** @hidden */
  16390. _generatePointsArray(): boolean;
  16391. /** @hidden */
  16392. _updateBoundingInfo(): AbstractMesh;
  16393. /**
  16394. * Creates a new InstancedMesh from the current mesh.
  16395. * - name (string) : the cloned mesh name
  16396. * - newParent (optional Node) : the optional Node to parent the clone to.
  16397. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16398. *
  16399. * Returns the clone.
  16400. */
  16401. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16402. /**
  16403. * Disposes the InstancedMesh.
  16404. * Returns nothing.
  16405. */
  16406. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16407. }
  16408. interface Mesh {
  16409. /**
  16410. * Register a custom buffer that will be instanced
  16411. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16412. * @param kind defines the buffer kind
  16413. * @param stride defines the stride in floats
  16414. */
  16415. registerInstancedBuffer(kind: string, stride: number): void;
  16416. /**
  16417. * true to use the edge renderer for all instances of this mesh
  16418. */
  16419. edgesShareWithInstances: boolean;
  16420. /** @hidden */
  16421. _userInstancedBuffersStorage: {
  16422. data: {
  16423. [key: string]: Float32Array;
  16424. };
  16425. sizes: {
  16426. [key: string]: number;
  16427. };
  16428. vertexBuffers: {
  16429. [key: string]: Nullable<VertexBuffer>;
  16430. };
  16431. strides: {
  16432. [key: string]: number;
  16433. };
  16434. };
  16435. }
  16436. interface AbstractMesh {
  16437. /**
  16438. * Object used to store instanced buffers defined by user
  16439. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16440. */
  16441. instancedBuffers: {
  16442. [key: string]: any;
  16443. };
  16444. }
  16445. }
  16446. declare module BABYLON {
  16447. /**
  16448. * Defines the options associated with the creation of a shader material.
  16449. */
  16450. export interface IShaderMaterialOptions {
  16451. /**
  16452. * Does the material work in alpha blend mode
  16453. */
  16454. needAlphaBlending: boolean;
  16455. /**
  16456. * Does the material work in alpha test mode
  16457. */
  16458. needAlphaTesting: boolean;
  16459. /**
  16460. * The list of attribute names used in the shader
  16461. */
  16462. attributes: string[];
  16463. /**
  16464. * The list of unifrom names used in the shader
  16465. */
  16466. uniforms: string[];
  16467. /**
  16468. * The list of UBO names used in the shader
  16469. */
  16470. uniformBuffers: string[];
  16471. /**
  16472. * The list of sampler names used in the shader
  16473. */
  16474. samplers: string[];
  16475. /**
  16476. * The list of defines used in the shader
  16477. */
  16478. defines: string[];
  16479. }
  16480. /**
  16481. * 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.
  16482. *
  16483. * This returned material effects how the mesh will look based on the code in the shaders.
  16484. *
  16485. * @see https://doc.babylonjs.com/how_to/shader_material
  16486. */
  16487. export class ShaderMaterial extends Material {
  16488. private _shaderPath;
  16489. private _options;
  16490. private _textures;
  16491. private _textureArrays;
  16492. private _floats;
  16493. private _ints;
  16494. private _floatsArrays;
  16495. private _colors3;
  16496. private _colors3Arrays;
  16497. private _colors4;
  16498. private _colors4Arrays;
  16499. private _vectors2;
  16500. private _vectors3;
  16501. private _vectors4;
  16502. private _matrices;
  16503. private _matrixArrays;
  16504. private _matrices3x3;
  16505. private _matrices2x2;
  16506. private _vectors2Arrays;
  16507. private _vectors3Arrays;
  16508. private _vectors4Arrays;
  16509. private _cachedWorldViewMatrix;
  16510. private _cachedWorldViewProjectionMatrix;
  16511. private _renderId;
  16512. private _multiview;
  16513. private _cachedDefines;
  16514. /** Define the Url to load snippets */
  16515. static SnippetUrl: string;
  16516. /** Snippet ID if the material was created from the snippet server */
  16517. snippetId: string;
  16518. /**
  16519. * Instantiate a new shader material.
  16520. * 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.
  16521. * This returned material effects how the mesh will look based on the code in the shaders.
  16522. * @see https://doc.babylonjs.com/how_to/shader_material
  16523. * @param name Define the name of the material in the scene
  16524. * @param scene Define the scene the material belongs to
  16525. * @param shaderPath Defines the route to the shader code in one of three ways:
  16526. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16527. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16528. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16529. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16530. * @param options Define the options used to create the shader
  16531. */
  16532. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16533. /**
  16534. * Gets the shader path used to define the shader code
  16535. * It can be modified to trigger a new compilation
  16536. */
  16537. get shaderPath(): any;
  16538. /**
  16539. * Sets the shader path used to define the shader code
  16540. * It can be modified to trigger a new compilation
  16541. */
  16542. set shaderPath(shaderPath: any);
  16543. /**
  16544. * Gets the options used to compile the shader.
  16545. * They can be modified to trigger a new compilation
  16546. */
  16547. get options(): IShaderMaterialOptions;
  16548. /**
  16549. * Gets the current class name of the material e.g. "ShaderMaterial"
  16550. * Mainly use in serialization.
  16551. * @returns the class name
  16552. */
  16553. getClassName(): string;
  16554. /**
  16555. * Specifies if the material will require alpha blending
  16556. * @returns a boolean specifying if alpha blending is needed
  16557. */
  16558. needAlphaBlending(): boolean;
  16559. /**
  16560. * Specifies if this material should be rendered in alpha test mode
  16561. * @returns a boolean specifying if an alpha test is needed.
  16562. */
  16563. needAlphaTesting(): boolean;
  16564. private _checkUniform;
  16565. /**
  16566. * Set a texture in the shader.
  16567. * @param name Define the name of the uniform samplers as defined in the shader
  16568. * @param texture Define the texture to bind to this sampler
  16569. * @return the material itself allowing "fluent" like uniform updates
  16570. */
  16571. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16572. /**
  16573. * Set a texture array in the shader.
  16574. * @param name Define the name of the uniform sampler array as defined in the shader
  16575. * @param textures Define the list of textures to bind to this sampler
  16576. * @return the material itself allowing "fluent" like uniform updates
  16577. */
  16578. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16579. /**
  16580. * Set a float in the shader.
  16581. * @param name Define the name of the uniform as defined in the shader
  16582. * @param value Define the value to give to the uniform
  16583. * @return the material itself allowing "fluent" like uniform updates
  16584. */
  16585. setFloat(name: string, value: number): ShaderMaterial;
  16586. /**
  16587. * Set a int in the shader.
  16588. * @param name Define the name of the uniform as defined in the shader
  16589. * @param value Define the value to give to the uniform
  16590. * @return the material itself allowing "fluent" like uniform updates
  16591. */
  16592. setInt(name: string, value: number): ShaderMaterial;
  16593. /**
  16594. * Set an array of floats in the shader.
  16595. * @param name Define the name of the uniform as defined in the shader
  16596. * @param value Define the value to give to the uniform
  16597. * @return the material itself allowing "fluent" like uniform updates
  16598. */
  16599. setFloats(name: string, value: number[]): ShaderMaterial;
  16600. /**
  16601. * Set a vec3 in the shader from a Color3.
  16602. * @param name Define the name of the uniform as defined in the shader
  16603. * @param value Define the value to give to the uniform
  16604. * @return the material itself allowing "fluent" like uniform updates
  16605. */
  16606. setColor3(name: string, value: Color3): ShaderMaterial;
  16607. /**
  16608. * Set a vec3 array in the shader from a Color3 array.
  16609. * @param name Define the name of the uniform as defined in the shader
  16610. * @param value Define the value to give to the uniform
  16611. * @return the material itself allowing "fluent" like uniform updates
  16612. */
  16613. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16614. /**
  16615. * Set a vec4 in the shader from a Color4.
  16616. * @param name Define the name of the uniform as defined in the shader
  16617. * @param value Define the value to give to the uniform
  16618. * @return the material itself allowing "fluent" like uniform updates
  16619. */
  16620. setColor4(name: string, value: Color4): ShaderMaterial;
  16621. /**
  16622. * Set a vec4 array in the shader from a Color4 array.
  16623. * @param name Define the name of the uniform as defined in the shader
  16624. * @param value Define the value to give to the uniform
  16625. * @return the material itself allowing "fluent" like uniform updates
  16626. */
  16627. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16628. /**
  16629. * Set a vec2 in the shader from a Vector2.
  16630. * @param name Define the name of the uniform as defined in the shader
  16631. * @param value Define the value to give to the uniform
  16632. * @return the material itself allowing "fluent" like uniform updates
  16633. */
  16634. setVector2(name: string, value: Vector2): ShaderMaterial;
  16635. /**
  16636. * Set a vec3 in the shader from a Vector3.
  16637. * @param name Define the name of the uniform as defined in the shader
  16638. * @param value Define the value to give to the uniform
  16639. * @return the material itself allowing "fluent" like uniform updates
  16640. */
  16641. setVector3(name: string, value: Vector3): ShaderMaterial;
  16642. /**
  16643. * Set a vec4 in the shader from a Vector4.
  16644. * @param name Define the name of the uniform as defined in the shader
  16645. * @param value Define the value to give to the uniform
  16646. * @return the material itself allowing "fluent" like uniform updates
  16647. */
  16648. setVector4(name: string, value: Vector4): ShaderMaterial;
  16649. /**
  16650. * Set a mat4 in the shader from a Matrix.
  16651. * @param name Define the name of the uniform as defined in the shader
  16652. * @param value Define the value to give to the uniform
  16653. * @return the material itself allowing "fluent" like uniform updates
  16654. */
  16655. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16656. /**
  16657. * Set a float32Array in the shader from a matrix array.
  16658. * @param name Define the name of the uniform as defined in the shader
  16659. * @param value Define the value to give to the uniform
  16660. * @return the material itself allowing "fluent" like uniform updates
  16661. */
  16662. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16663. /**
  16664. * Set a mat3 in the shader from a Float32Array.
  16665. * @param name Define the name of the uniform as defined in the shader
  16666. * @param value Define the value to give to the uniform
  16667. * @return the material itself allowing "fluent" like uniform updates
  16668. */
  16669. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16670. /**
  16671. * Set a mat2 in the shader from a Float32Array.
  16672. * @param name Define the name of the uniform as defined in the shader
  16673. * @param value Define the value to give to the uniform
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16677. /**
  16678. * Set a vec2 array in the shader from a number array.
  16679. * @param name Define the name of the uniform as defined in the shader
  16680. * @param value Define the value to give to the uniform
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setArray2(name: string, value: number[]): ShaderMaterial;
  16684. /**
  16685. * Set a vec3 array in the shader from a number array.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the material itself allowing "fluent" like uniform updates
  16689. */
  16690. setArray3(name: string, value: number[]): ShaderMaterial;
  16691. /**
  16692. * Set a vec4 array in the shader from a number array.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the material itself allowing "fluent" like uniform updates
  16696. */
  16697. setArray4(name: string, value: number[]): ShaderMaterial;
  16698. private _checkCache;
  16699. /**
  16700. * Specifies that the submesh is ready to be used
  16701. * @param mesh defines the mesh to check
  16702. * @param subMesh defines which submesh to check
  16703. * @param useInstances specifies that instances should be used
  16704. * @returns a boolean indicating that the submesh is ready or not
  16705. */
  16706. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16707. /**
  16708. * Checks if the material is ready to render the requested mesh
  16709. * @param mesh Define the mesh to render
  16710. * @param useInstances Define whether or not the material is used with instances
  16711. * @returns true if ready, otherwise false
  16712. */
  16713. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16714. /**
  16715. * Binds the world matrix to the material
  16716. * @param world defines the world transformation matrix
  16717. * @param effectOverride - If provided, use this effect instead of internal effect
  16718. */
  16719. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16720. /**
  16721. * Binds the submesh to this material by preparing the effect and shader to draw
  16722. * @param world defines the world transformation matrix
  16723. * @param mesh defines the mesh containing the submesh
  16724. * @param subMesh defines the submesh to bind the material to
  16725. */
  16726. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16727. /**
  16728. * Binds the material to the mesh
  16729. * @param world defines the world transformation matrix
  16730. * @param mesh defines the mesh to bind the material to
  16731. * @param effectOverride - If provided, use this effect instead of internal effect
  16732. */
  16733. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16734. protected _afterBind(mesh?: Mesh): void;
  16735. /**
  16736. * Gets the active textures from the material
  16737. * @returns an array of textures
  16738. */
  16739. getActiveTextures(): BaseTexture[];
  16740. /**
  16741. * Specifies if the material uses a texture
  16742. * @param texture defines the texture to check against the material
  16743. * @returns a boolean specifying if the material uses the texture
  16744. */
  16745. hasTexture(texture: BaseTexture): boolean;
  16746. /**
  16747. * Makes a duplicate of the material, and gives it a new name
  16748. * @param name defines the new name for the duplicated material
  16749. * @returns the cloned material
  16750. */
  16751. clone(name: string): ShaderMaterial;
  16752. /**
  16753. * Disposes the material
  16754. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16755. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16756. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16757. */
  16758. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16759. /**
  16760. * Serializes this material in a JSON representation
  16761. * @returns the serialized material object
  16762. */
  16763. serialize(): any;
  16764. /**
  16765. * Creates a shader material from parsed shader material data
  16766. * @param source defines the JSON represnetation of the material
  16767. * @param scene defines the hosting scene
  16768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16769. * @returns a new material
  16770. */
  16771. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16772. /**
  16773. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16774. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16775. * @param url defines the url to load from
  16776. * @param scene defines the hosting scene
  16777. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16778. * @returns a promise that will resolve to the new ShaderMaterial
  16779. */
  16780. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16781. /**
  16782. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16783. * @param snippetId defines the snippet to load
  16784. * @param scene defines the hosting scene
  16785. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16786. * @returns a promise that will resolve to the new ShaderMaterial
  16787. */
  16788. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16789. }
  16790. }
  16791. declare module BABYLON {
  16792. /** @hidden */
  16793. export var colorPixelShader: {
  16794. name: string;
  16795. shader: string;
  16796. };
  16797. }
  16798. declare module BABYLON {
  16799. /** @hidden */
  16800. export var colorVertexShader: {
  16801. name: string;
  16802. shader: string;
  16803. };
  16804. }
  16805. declare module BABYLON {
  16806. /**
  16807. * Line mesh
  16808. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16809. */
  16810. export class LinesMesh extends Mesh {
  16811. /**
  16812. * If vertex color should be applied to the mesh
  16813. */
  16814. readonly useVertexColor?: boolean | undefined;
  16815. /**
  16816. * If vertex alpha should be applied to the mesh
  16817. */
  16818. readonly useVertexAlpha?: boolean | undefined;
  16819. /**
  16820. * Color of the line (Default: White)
  16821. */
  16822. color: Color3;
  16823. /**
  16824. * Alpha of the line (Default: 1)
  16825. */
  16826. alpha: number;
  16827. /**
  16828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16829. * This margin is expressed in world space coordinates, so its value may vary.
  16830. * Default value is 0.1
  16831. */
  16832. intersectionThreshold: number;
  16833. private _colorShader;
  16834. private color4;
  16835. /**
  16836. * Creates a new LinesMesh
  16837. * @param name defines the name
  16838. * @param scene defines the hosting scene
  16839. * @param parent defines the parent mesh if any
  16840. * @param source defines the optional source LinesMesh used to clone data from
  16841. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16842. * When false, achieved by calling a clone(), also passing False.
  16843. * This will make creation of children, recursive.
  16844. * @param useVertexColor defines if this LinesMesh supports vertex color
  16845. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16846. */
  16847. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16848. /**
  16849. * If vertex color should be applied to the mesh
  16850. */
  16851. useVertexColor?: boolean | undefined,
  16852. /**
  16853. * If vertex alpha should be applied to the mesh
  16854. */
  16855. useVertexAlpha?: boolean | undefined);
  16856. private _addClipPlaneDefine;
  16857. private _removeClipPlaneDefine;
  16858. isReady(): boolean;
  16859. /**
  16860. * Returns the string "LineMesh"
  16861. */
  16862. getClassName(): string;
  16863. /**
  16864. * @hidden
  16865. */
  16866. get material(): Material;
  16867. /**
  16868. * @hidden
  16869. */
  16870. set material(value: Material);
  16871. /**
  16872. * @hidden
  16873. */
  16874. get checkCollisions(): boolean;
  16875. /** @hidden */
  16876. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16877. /** @hidden */
  16878. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16879. /**
  16880. * Disposes of the line mesh
  16881. * @param doNotRecurse If children should be disposed
  16882. */
  16883. dispose(doNotRecurse?: boolean): void;
  16884. /**
  16885. * Returns a new LineMesh object cloned from the current one.
  16886. */
  16887. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16888. /**
  16889. * Creates a new InstancedLinesMesh object from the mesh model.
  16890. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16891. * @param name defines the name of the new instance
  16892. * @returns a new InstancedLinesMesh
  16893. */
  16894. createInstance(name: string): InstancedLinesMesh;
  16895. }
  16896. /**
  16897. * Creates an instance based on a source LinesMesh
  16898. */
  16899. export class InstancedLinesMesh extends InstancedMesh {
  16900. /**
  16901. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16902. * This margin is expressed in world space coordinates, so its value may vary.
  16903. * Initilized with the intersectionThreshold value of the source LinesMesh
  16904. */
  16905. intersectionThreshold: number;
  16906. constructor(name: string, source: LinesMesh);
  16907. /**
  16908. * Returns the string "InstancedLinesMesh".
  16909. */
  16910. getClassName(): string;
  16911. }
  16912. }
  16913. declare module BABYLON {
  16914. /** @hidden */
  16915. export var linePixelShader: {
  16916. name: string;
  16917. shader: string;
  16918. };
  16919. }
  16920. declare module BABYLON {
  16921. /** @hidden */
  16922. export var lineVertexShader: {
  16923. name: string;
  16924. shader: string;
  16925. };
  16926. }
  16927. declare module BABYLON {
  16928. interface Scene {
  16929. /** @hidden */
  16930. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16931. }
  16932. interface AbstractMesh {
  16933. /**
  16934. * Gets the edgesRenderer associated with the mesh
  16935. */
  16936. edgesRenderer: Nullable<EdgesRenderer>;
  16937. }
  16938. interface LinesMesh {
  16939. /**
  16940. * Enables the edge rendering mode on the mesh.
  16941. * This mode makes the mesh edges visible
  16942. * @param epsilon defines the maximal distance between two angles to detect a face
  16943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16944. * @returns the currentAbstractMesh
  16945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16946. */
  16947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16948. }
  16949. interface InstancedLinesMesh {
  16950. /**
  16951. * Enables the edge rendering mode on the mesh.
  16952. * This mode makes the mesh edges visible
  16953. * @param epsilon defines the maximal distance between two angles to detect a face
  16954. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16955. * @returns the current InstancedLinesMesh
  16956. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16957. */
  16958. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16959. }
  16960. /**
  16961. * Defines the minimum contract an Edges renderer should follow.
  16962. */
  16963. export interface IEdgesRenderer extends IDisposable {
  16964. /**
  16965. * Gets or sets a boolean indicating if the edgesRenderer is active
  16966. */
  16967. isEnabled: boolean;
  16968. /**
  16969. * Renders the edges of the attached mesh,
  16970. */
  16971. render(): void;
  16972. /**
  16973. * Checks wether or not the edges renderer is ready to render.
  16974. * @return true if ready, otherwise false.
  16975. */
  16976. isReady(): boolean;
  16977. /**
  16978. * List of instances to render in case the source mesh has instances
  16979. */
  16980. customInstances: SmartArray<Matrix>;
  16981. }
  16982. /**
  16983. * Defines the additional options of the edges renderer
  16984. */
  16985. export interface IEdgesRendererOptions {
  16986. /**
  16987. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16988. * If not defined, the default value is true
  16989. */
  16990. useAlternateEdgeFinder?: boolean;
  16991. /**
  16992. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16993. * If not defined, the default value is true.
  16994. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  16995. * This option is used only if useAlternateEdgeFinder = true
  16996. */
  16997. useFastVertexMerger?: boolean;
  16998. /**
  16999. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17000. * The default value is 1e-6
  17001. * This option is used only if useAlternateEdgeFinder = true
  17002. */
  17003. epsilonVertexMerge?: number;
  17004. /**
  17005. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17006. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17007. * This option is used only if useAlternateEdgeFinder = true
  17008. */
  17009. applyTessellation?: boolean;
  17010. /**
  17011. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17012. * The default value is 1e-6
  17013. * This option is used only if useAlternateEdgeFinder = true
  17014. */
  17015. epsilonVertexAligned?: number;
  17016. }
  17017. /**
  17018. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17019. */
  17020. export class EdgesRenderer implements IEdgesRenderer {
  17021. /**
  17022. * Define the size of the edges with an orthographic camera
  17023. */
  17024. edgesWidthScalerForOrthographic: number;
  17025. /**
  17026. * Define the size of the edges with a perspective camera
  17027. */
  17028. edgesWidthScalerForPerspective: number;
  17029. protected _source: AbstractMesh;
  17030. protected _linesPositions: number[];
  17031. protected _linesNormals: number[];
  17032. protected _linesIndices: number[];
  17033. protected _epsilon: number;
  17034. protected _indicesCount: number;
  17035. protected _lineShader: ShaderMaterial;
  17036. protected _ib: DataBuffer;
  17037. protected _buffers: {
  17038. [key: string]: Nullable<VertexBuffer>;
  17039. };
  17040. protected _buffersForInstances: {
  17041. [key: string]: Nullable<VertexBuffer>;
  17042. };
  17043. protected _checkVerticesInsteadOfIndices: boolean;
  17044. protected _options: Nullable<IEdgesRendererOptions>;
  17045. private _meshRebuildObserver;
  17046. private _meshDisposeObserver;
  17047. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17048. isEnabled: boolean;
  17049. /**
  17050. * List of instances to render in case the source mesh has instances
  17051. */
  17052. customInstances: SmartArray<Matrix>;
  17053. private static GetShader;
  17054. /**
  17055. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17056. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17057. * @param source Mesh used to create edges
  17058. * @param epsilon sum of angles in adjacency to check for edge
  17059. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17060. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17061. * @param options The options to apply when generating the edges
  17062. */
  17063. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17064. protected _prepareRessources(): void;
  17065. /** @hidden */
  17066. _rebuild(): void;
  17067. /**
  17068. * Releases the required resources for the edges renderer
  17069. */
  17070. dispose(): void;
  17071. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17072. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17073. /**
  17074. * Checks if the pair of p0 and p1 is en edge
  17075. * @param faceIndex
  17076. * @param edge
  17077. * @param faceNormals
  17078. * @param p0
  17079. * @param p1
  17080. * @private
  17081. */
  17082. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17083. /**
  17084. * push line into the position, normal and index buffer
  17085. * @protected
  17086. */
  17087. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17088. /**
  17089. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17090. */
  17091. private _tessellateTriangle;
  17092. private _generateEdgesLinesAlternate;
  17093. /**
  17094. * Generates lines edges from adjacencjes
  17095. * @private
  17096. */
  17097. _generateEdgesLines(): void;
  17098. /**
  17099. * Checks wether or not the edges renderer is ready to render.
  17100. * @return true if ready, otherwise false.
  17101. */
  17102. isReady(): boolean;
  17103. /**
  17104. * Renders the edges of the attached mesh,
  17105. */
  17106. render(): void;
  17107. }
  17108. /**
  17109. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17110. */
  17111. export class LineEdgesRenderer extends EdgesRenderer {
  17112. /**
  17113. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17114. * @param source LineMesh used to generate edges
  17115. * @param epsilon not important (specified angle for edge detection)
  17116. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17117. */
  17118. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17119. /**
  17120. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17121. */
  17122. _generateEdgesLines(): void;
  17123. }
  17124. }
  17125. declare module BABYLON {
  17126. /**
  17127. * This represents the object necessary to create a rendering group.
  17128. * This is exclusively used and created by the rendering manager.
  17129. * To modify the behavior, you use the available helpers in your scene or meshes.
  17130. * @hidden
  17131. */
  17132. export class RenderingGroup {
  17133. index: number;
  17134. private static _zeroVector;
  17135. private _scene;
  17136. private _opaqueSubMeshes;
  17137. private _transparentSubMeshes;
  17138. private _alphaTestSubMeshes;
  17139. private _depthOnlySubMeshes;
  17140. private _particleSystems;
  17141. private _spriteManagers;
  17142. private _opaqueSortCompareFn;
  17143. private _alphaTestSortCompareFn;
  17144. private _transparentSortCompareFn;
  17145. private _renderOpaque;
  17146. private _renderAlphaTest;
  17147. private _renderTransparent;
  17148. /** @hidden */
  17149. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17150. onBeforeTransparentRendering: () => void;
  17151. /**
  17152. * Set the opaque sort comparison function.
  17153. * If null the sub meshes will be render in the order they were created
  17154. */
  17155. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17156. /**
  17157. * Set the alpha test sort comparison function.
  17158. * If null the sub meshes will be render in the order they were created
  17159. */
  17160. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17161. /**
  17162. * Set the transparent sort comparison function.
  17163. * If null the sub meshes will be render in the order they were created
  17164. */
  17165. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17166. /**
  17167. * Creates a new rendering group.
  17168. * @param index The rendering group index
  17169. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17170. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17171. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17172. */
  17173. 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>);
  17174. /**
  17175. * Render all the sub meshes contained in the group.
  17176. * @param customRenderFunction Used to override the default render behaviour of the group.
  17177. * @returns true if rendered some submeshes.
  17178. */
  17179. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17180. /**
  17181. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17182. * @param subMeshes The submeshes to render
  17183. */
  17184. private renderOpaqueSorted;
  17185. /**
  17186. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17187. * @param subMeshes The submeshes to render
  17188. */
  17189. private renderAlphaTestSorted;
  17190. /**
  17191. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17192. * @param subMeshes The submeshes to render
  17193. */
  17194. private renderTransparentSorted;
  17195. /**
  17196. * Renders the submeshes in a specified order.
  17197. * @param subMeshes The submeshes to sort before render
  17198. * @param sortCompareFn The comparison function use to sort
  17199. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17200. * @param transparent Specifies to activate blending if true
  17201. */
  17202. private static renderSorted;
  17203. /**
  17204. * Renders the submeshes in the order they were dispatched (no sort applied).
  17205. * @param subMeshes The submeshes to render
  17206. */
  17207. private static renderUnsorted;
  17208. /**
  17209. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17210. * are rendered back to front if in the same alpha index.
  17211. *
  17212. * @param a The first submesh
  17213. * @param b The second submesh
  17214. * @returns The result of the comparison
  17215. */
  17216. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17217. /**
  17218. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17219. * are rendered back to front.
  17220. *
  17221. * @param a The first submesh
  17222. * @param b The second submesh
  17223. * @returns The result of the comparison
  17224. */
  17225. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17226. /**
  17227. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17228. * are rendered front to back (prevent overdraw).
  17229. *
  17230. * @param a The first submesh
  17231. * @param b The second submesh
  17232. * @returns The result of the comparison
  17233. */
  17234. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17235. /**
  17236. * Resets the different lists of submeshes to prepare a new frame.
  17237. */
  17238. prepare(): void;
  17239. dispose(): void;
  17240. /**
  17241. * Inserts the submesh in its correct queue depending on its material.
  17242. * @param subMesh The submesh to dispatch
  17243. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17244. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17245. */
  17246. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17247. dispatchSprites(spriteManager: ISpriteManager): void;
  17248. dispatchParticles(particleSystem: IParticleSystem): void;
  17249. private _renderParticles;
  17250. private _renderSprites;
  17251. }
  17252. }
  17253. declare module BABYLON {
  17254. /**
  17255. * Interface describing the different options available in the rendering manager
  17256. * regarding Auto Clear between groups.
  17257. */
  17258. export interface IRenderingManagerAutoClearSetup {
  17259. /**
  17260. * Defines whether or not autoclear is enable.
  17261. */
  17262. autoClear: boolean;
  17263. /**
  17264. * Defines whether or not to autoclear the depth buffer.
  17265. */
  17266. depth: boolean;
  17267. /**
  17268. * Defines whether or not to autoclear the stencil buffer.
  17269. */
  17270. stencil: boolean;
  17271. }
  17272. /**
  17273. * This class is used by the onRenderingGroupObservable
  17274. */
  17275. export class RenderingGroupInfo {
  17276. /**
  17277. * The Scene that being rendered
  17278. */
  17279. scene: Scene;
  17280. /**
  17281. * The camera currently used for the rendering pass
  17282. */
  17283. camera: Nullable<Camera>;
  17284. /**
  17285. * The ID of the renderingGroup being processed
  17286. */
  17287. renderingGroupId: number;
  17288. }
  17289. /**
  17290. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17291. * It is enable to manage the different groups as well as the different necessary sort functions.
  17292. * This should not be used directly aside of the few static configurations
  17293. */
  17294. export class RenderingManager {
  17295. /**
  17296. * The max id used for rendering groups (not included)
  17297. */
  17298. static MAX_RENDERINGGROUPS: number;
  17299. /**
  17300. * The min id used for rendering groups (included)
  17301. */
  17302. static MIN_RENDERINGGROUPS: number;
  17303. /**
  17304. * Used to globally prevent autoclearing scenes.
  17305. */
  17306. static AUTOCLEAR: boolean;
  17307. /**
  17308. * @hidden
  17309. */
  17310. _useSceneAutoClearSetup: boolean;
  17311. private _scene;
  17312. private _renderingGroups;
  17313. private _depthStencilBufferAlreadyCleaned;
  17314. private _autoClearDepthStencil;
  17315. private _customOpaqueSortCompareFn;
  17316. private _customAlphaTestSortCompareFn;
  17317. private _customTransparentSortCompareFn;
  17318. private _renderingGroupInfo;
  17319. /**
  17320. * Instantiates a new rendering group for a particular scene
  17321. * @param scene Defines the scene the groups belongs to
  17322. */
  17323. constructor(scene: Scene);
  17324. private _clearDepthStencilBuffer;
  17325. /**
  17326. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17327. * @hidden
  17328. */
  17329. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17330. /**
  17331. * Resets the different information of the group to prepare a new frame
  17332. * @hidden
  17333. */
  17334. reset(): void;
  17335. /**
  17336. * Dispose and release the group and its associated resources.
  17337. * @hidden
  17338. */
  17339. dispose(): void;
  17340. /**
  17341. * Clear the info related to rendering groups preventing retention points during dispose.
  17342. */
  17343. freeRenderingGroups(): void;
  17344. private _prepareRenderingGroup;
  17345. /**
  17346. * Add a sprite manager to the rendering manager in order to render it this frame.
  17347. * @param spriteManager Define the sprite manager to render
  17348. */
  17349. dispatchSprites(spriteManager: ISpriteManager): void;
  17350. /**
  17351. * Add a particle system to the rendering manager in order to render it this frame.
  17352. * @param particleSystem Define the particle system to render
  17353. */
  17354. dispatchParticles(particleSystem: IParticleSystem): void;
  17355. /**
  17356. * Add a submesh to the manager in order to render it this frame
  17357. * @param subMesh The submesh to dispatch
  17358. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17359. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17360. */
  17361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17362. /**
  17363. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17364. * This allowed control for front to back rendering or reversly depending of the special needs.
  17365. *
  17366. * @param renderingGroupId The rendering group id corresponding to its index
  17367. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17368. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17369. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17370. */
  17371. 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;
  17372. /**
  17373. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17374. *
  17375. * @param renderingGroupId The rendering group id corresponding to its index
  17376. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17377. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17378. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17379. */
  17380. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17381. /**
  17382. * Gets the current auto clear configuration for one rendering group of the rendering
  17383. * manager.
  17384. * @param index the rendering group index to get the information for
  17385. * @returns The auto clear setup for the requested rendering group
  17386. */
  17387. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17388. }
  17389. }
  17390. declare module BABYLON {
  17391. /**
  17392. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17393. */
  17394. export interface ICustomShaderOptions {
  17395. /**
  17396. * Gets or sets the custom shader name to use
  17397. */
  17398. shaderName: string;
  17399. /**
  17400. * The list of attribute names used in the shader
  17401. */
  17402. attributes?: string[];
  17403. /**
  17404. * The list of unifrom names used in the shader
  17405. */
  17406. uniforms?: string[];
  17407. /**
  17408. * The list of sampler names used in the shader
  17409. */
  17410. samplers?: string[];
  17411. /**
  17412. * The list of defines used in the shader
  17413. */
  17414. defines?: string[];
  17415. }
  17416. /**
  17417. * Interface to implement to create a shadow generator compatible with BJS.
  17418. */
  17419. export interface IShadowGenerator {
  17420. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17421. id: string;
  17422. /**
  17423. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17424. * @returns The render target texture if present otherwise, null
  17425. */
  17426. getShadowMap(): Nullable<RenderTargetTexture>;
  17427. /**
  17428. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17429. * @param subMesh The submesh we want to render in the shadow map
  17430. * @param useInstances Defines wether will draw in the map using instances
  17431. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17432. * @returns true if ready otherwise, false
  17433. */
  17434. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17435. /**
  17436. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17437. * @param defines Defines of the material we want to update
  17438. * @param lightIndex Index of the light in the enabled light list of the material
  17439. */
  17440. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17441. /**
  17442. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17443. * defined in the generator but impacting the effect).
  17444. * It implies the unifroms available on the materials are the standard BJS ones.
  17445. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17446. * @param effect The effect we are binfing the information for
  17447. */
  17448. bindShadowLight(lightIndex: string, effect: Effect): void;
  17449. /**
  17450. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17451. * (eq to shadow prjection matrix * light transform matrix)
  17452. * @returns The transform matrix used to create the shadow map
  17453. */
  17454. getTransformMatrix(): Matrix;
  17455. /**
  17456. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17457. * Cube and 2D textures for instance.
  17458. */
  17459. recreateShadowMap(): void;
  17460. /**
  17461. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17462. * @param onCompiled Callback triggered at the and of the effects compilation
  17463. * @param options Sets of optional options forcing the compilation with different modes
  17464. */
  17465. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17466. useInstances: boolean;
  17467. }>): void;
  17468. /**
  17469. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17470. * @param options Sets of optional options forcing the compilation with different modes
  17471. * @returns A promise that resolves when the compilation completes
  17472. */
  17473. forceCompilationAsync(options?: Partial<{
  17474. useInstances: boolean;
  17475. }>): Promise<void>;
  17476. /**
  17477. * Serializes the shadow generator setup to a json object.
  17478. * @returns The serialized JSON object
  17479. */
  17480. serialize(): any;
  17481. /**
  17482. * Disposes the Shadow map and related Textures and effects.
  17483. */
  17484. dispose(): void;
  17485. }
  17486. /**
  17487. * Default implementation IShadowGenerator.
  17488. * This is the main object responsible of generating shadows in the framework.
  17489. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17490. */
  17491. export class ShadowGenerator implements IShadowGenerator {
  17492. /**
  17493. * Name of the shadow generator class
  17494. */
  17495. static CLASSNAME: string;
  17496. /**
  17497. * Shadow generator mode None: no filtering applied.
  17498. */
  17499. static readonly FILTER_NONE: number;
  17500. /**
  17501. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17503. */
  17504. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17505. /**
  17506. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17507. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17508. */
  17509. static readonly FILTER_POISSONSAMPLING: number;
  17510. /**
  17511. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17513. */
  17514. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17515. /**
  17516. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17517. * edge artifacts on steep falloff.
  17518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17519. */
  17520. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17521. /**
  17522. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17523. * edge artifacts on steep falloff.
  17524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17525. */
  17526. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17527. /**
  17528. * Shadow generator mode PCF: Percentage Closer Filtering
  17529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17530. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17531. */
  17532. static readonly FILTER_PCF: number;
  17533. /**
  17534. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17535. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17536. * Contact Hardening
  17537. */
  17538. static readonly FILTER_PCSS: number;
  17539. /**
  17540. * Reserved for PCF and PCSS
  17541. * Highest Quality.
  17542. *
  17543. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17544. *
  17545. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17546. */
  17547. static readonly QUALITY_HIGH: number;
  17548. /**
  17549. * Reserved for PCF and PCSS
  17550. * Good tradeoff for quality/perf cross devices
  17551. *
  17552. * Execute PCF on a 3*3 kernel.
  17553. *
  17554. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17555. */
  17556. static readonly QUALITY_MEDIUM: number;
  17557. /**
  17558. * Reserved for PCF and PCSS
  17559. * The lowest quality but the fastest.
  17560. *
  17561. * Execute PCF on a 1*1 kernel.
  17562. *
  17563. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17564. */
  17565. static readonly QUALITY_LOW: number;
  17566. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17567. id: string;
  17568. /** Gets or sets the custom shader name to use */
  17569. customShaderOptions: ICustomShaderOptions;
  17570. /**
  17571. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17572. */
  17573. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17574. /**
  17575. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17576. */
  17577. onAfterShadowMapRenderObservable: Observable<Effect>;
  17578. /**
  17579. * Observable triggered before a mesh is rendered in the shadow map.
  17580. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17581. */
  17582. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17583. /**
  17584. * Observable triggered after a mesh is rendered in the shadow map.
  17585. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17586. */
  17587. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17588. protected _bias: number;
  17589. /**
  17590. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17591. */
  17592. get bias(): number;
  17593. /**
  17594. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17595. */
  17596. set bias(bias: number);
  17597. protected _normalBias: number;
  17598. /**
  17599. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17600. */
  17601. get normalBias(): number;
  17602. /**
  17603. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17604. */
  17605. set normalBias(normalBias: number);
  17606. protected _blurBoxOffset: number;
  17607. /**
  17608. * Gets the blur box offset: offset applied during the blur pass.
  17609. * Only useful if useKernelBlur = false
  17610. */
  17611. get blurBoxOffset(): number;
  17612. /**
  17613. * Sets the blur box offset: offset applied during the blur pass.
  17614. * Only useful if useKernelBlur = false
  17615. */
  17616. set blurBoxOffset(value: number);
  17617. protected _blurScale: number;
  17618. /**
  17619. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17620. * 2 means half of the size.
  17621. */
  17622. get blurScale(): number;
  17623. /**
  17624. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17625. * 2 means half of the size.
  17626. */
  17627. set blurScale(value: number);
  17628. protected _blurKernel: number;
  17629. /**
  17630. * Gets the blur kernel: kernel size of the blur pass.
  17631. * Only useful if useKernelBlur = true
  17632. */
  17633. get blurKernel(): number;
  17634. /**
  17635. * Sets the blur kernel: kernel size of the blur pass.
  17636. * Only useful if useKernelBlur = true
  17637. */
  17638. set blurKernel(value: number);
  17639. protected _useKernelBlur: boolean;
  17640. /**
  17641. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17642. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17643. */
  17644. get useKernelBlur(): boolean;
  17645. /**
  17646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17648. */
  17649. set useKernelBlur(value: boolean);
  17650. protected _depthScale: number;
  17651. /**
  17652. * Gets the depth scale used in ESM mode.
  17653. */
  17654. get depthScale(): number;
  17655. /**
  17656. * Sets the depth scale used in ESM mode.
  17657. * This can override the scale stored on the light.
  17658. */
  17659. set depthScale(value: number);
  17660. protected _validateFilter(filter: number): number;
  17661. protected _filter: number;
  17662. /**
  17663. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17664. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17665. */
  17666. get filter(): number;
  17667. /**
  17668. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17669. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17670. */
  17671. set filter(value: number);
  17672. /**
  17673. * Gets if the current filter is set to Poisson Sampling.
  17674. */
  17675. get usePoissonSampling(): boolean;
  17676. /**
  17677. * Sets the current filter to Poisson Sampling.
  17678. */
  17679. set usePoissonSampling(value: boolean);
  17680. /**
  17681. * Gets if the current filter is set to ESM.
  17682. */
  17683. get useExponentialShadowMap(): boolean;
  17684. /**
  17685. * Sets the current filter is to ESM.
  17686. */
  17687. set useExponentialShadowMap(value: boolean);
  17688. /**
  17689. * Gets if the current filter is set to filtered ESM.
  17690. */
  17691. get useBlurExponentialShadowMap(): boolean;
  17692. /**
  17693. * Gets if the current filter is set to filtered ESM.
  17694. */
  17695. set useBlurExponentialShadowMap(value: boolean);
  17696. /**
  17697. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17698. * exponential to prevent steep falloff artifacts).
  17699. */
  17700. get useCloseExponentialShadowMap(): boolean;
  17701. /**
  17702. * Sets the current filter to "close ESM" (using the inverse of the
  17703. * exponential to prevent steep falloff artifacts).
  17704. */
  17705. set useCloseExponentialShadowMap(value: boolean);
  17706. /**
  17707. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17708. * exponential to prevent steep falloff artifacts).
  17709. */
  17710. get useBlurCloseExponentialShadowMap(): boolean;
  17711. /**
  17712. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17713. * exponential to prevent steep falloff artifacts).
  17714. */
  17715. set useBlurCloseExponentialShadowMap(value: boolean);
  17716. /**
  17717. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17718. */
  17719. get usePercentageCloserFiltering(): boolean;
  17720. /**
  17721. * Sets the current filter to "PCF" (percentage closer filtering).
  17722. */
  17723. set usePercentageCloserFiltering(value: boolean);
  17724. protected _filteringQuality: number;
  17725. /**
  17726. * Gets the PCF or PCSS Quality.
  17727. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17728. */
  17729. get filteringQuality(): number;
  17730. /**
  17731. * Sets the PCF or PCSS Quality.
  17732. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17733. */
  17734. set filteringQuality(filteringQuality: number);
  17735. /**
  17736. * Gets if the current filter is set to "PCSS" (contact hardening).
  17737. */
  17738. get useContactHardeningShadow(): boolean;
  17739. /**
  17740. * Sets the current filter to "PCSS" (contact hardening).
  17741. */
  17742. set useContactHardeningShadow(value: boolean);
  17743. protected _contactHardeningLightSizeUVRatio: number;
  17744. /**
  17745. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17746. * Using a ratio helps keeping shape stability independently of the map size.
  17747. *
  17748. * It does not account for the light projection as it was having too much
  17749. * instability during the light setup or during light position changes.
  17750. *
  17751. * Only valid if useContactHardeningShadow is true.
  17752. */
  17753. get contactHardeningLightSizeUVRatio(): number;
  17754. /**
  17755. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17756. * Using a ratio helps keeping shape stability independently of the map size.
  17757. *
  17758. * It does not account for the light projection as it was having too much
  17759. * instability during the light setup or during light position changes.
  17760. *
  17761. * Only valid if useContactHardeningShadow is true.
  17762. */
  17763. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17764. protected _darkness: number;
  17765. /** Gets or sets the actual darkness of a shadow */
  17766. get darkness(): number;
  17767. set darkness(value: number);
  17768. /**
  17769. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17770. * 0 means strongest and 1 would means no shadow.
  17771. * @returns the darkness.
  17772. */
  17773. getDarkness(): number;
  17774. /**
  17775. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17776. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17777. * @returns the shadow generator allowing fluent coding.
  17778. */
  17779. setDarkness(darkness: number): ShadowGenerator;
  17780. protected _transparencyShadow: boolean;
  17781. /** Gets or sets the ability to have transparent shadow */
  17782. get transparencyShadow(): boolean;
  17783. set transparencyShadow(value: boolean);
  17784. /**
  17785. * Sets the ability to have transparent shadow (boolean).
  17786. * @param transparent True if transparent else False
  17787. * @returns the shadow generator allowing fluent coding
  17788. */
  17789. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17790. /**
  17791. * Enables or disables shadows with varying strength based on the transparency
  17792. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17793. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17794. * mesh.visibility * alphaTexture.a
  17795. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17796. */
  17797. enableSoftTransparentShadow: boolean;
  17798. protected _shadowMap: Nullable<RenderTargetTexture>;
  17799. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17800. /**
  17801. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17802. * @returns The render target texture if present otherwise, null
  17803. */
  17804. getShadowMap(): Nullable<RenderTargetTexture>;
  17805. /**
  17806. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17807. * @returns The render target texture if the shadow map is present otherwise, null
  17808. */
  17809. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17810. /**
  17811. * Gets the class name of that object
  17812. * @returns "ShadowGenerator"
  17813. */
  17814. getClassName(): string;
  17815. /**
  17816. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17817. * @param mesh Mesh to add
  17818. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17819. * @returns the Shadow Generator itself
  17820. */
  17821. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17822. /**
  17823. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17824. * @param mesh Mesh to remove
  17825. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17826. * @returns the Shadow Generator itself
  17827. */
  17828. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17829. /**
  17830. * Controls the extent to which the shadows fade out at the edge of the frustum
  17831. */
  17832. frustumEdgeFalloff: number;
  17833. protected _light: IShadowLight;
  17834. /**
  17835. * Returns the associated light object.
  17836. * @returns the light generating the shadow
  17837. */
  17838. getLight(): IShadowLight;
  17839. /**
  17840. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17841. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17842. * It might on the other hand introduce peter panning.
  17843. */
  17844. forceBackFacesOnly: boolean;
  17845. protected _scene: Scene;
  17846. protected _lightDirection: Vector3;
  17847. protected _effect: Effect;
  17848. protected _viewMatrix: Matrix;
  17849. protected _projectionMatrix: Matrix;
  17850. protected _transformMatrix: Matrix;
  17851. protected _cachedPosition: Vector3;
  17852. protected _cachedDirection: Vector3;
  17853. protected _cachedDefines: string;
  17854. protected _currentRenderID: number;
  17855. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17856. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17857. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17858. protected _blurPostProcesses: PostProcess[];
  17859. protected _mapSize: number;
  17860. protected _currentFaceIndex: number;
  17861. protected _currentFaceIndexCache: number;
  17862. protected _textureType: number;
  17863. protected _defaultTextureMatrix: Matrix;
  17864. protected _storedUniqueId: Nullable<number>;
  17865. /** @hidden */
  17866. static _SceneComponentInitialization: (scene: Scene) => void;
  17867. /**
  17868. * Creates a ShadowGenerator object.
  17869. * A ShadowGenerator is the required tool to use the shadows.
  17870. * Each light casting shadows needs to use its own ShadowGenerator.
  17871. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17872. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17873. * @param light The light object generating the shadows.
  17874. * @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.
  17875. */
  17876. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17877. protected _initializeGenerator(): void;
  17878. protected _createTargetRenderTexture(): void;
  17879. protected _initializeShadowMap(): void;
  17880. protected _initializeBlurRTTAndPostProcesses(): void;
  17881. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17882. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17883. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17884. protected _applyFilterValues(): void;
  17885. /**
  17886. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17887. * @param onCompiled Callback triggered at the and of the effects compilation
  17888. * @param options Sets of optional options forcing the compilation with different modes
  17889. */
  17890. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17891. useInstances: boolean;
  17892. }>): void;
  17893. /**
  17894. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17895. * @param options Sets of optional options forcing the compilation with different modes
  17896. * @returns A promise that resolves when the compilation completes
  17897. */
  17898. forceCompilationAsync(options?: Partial<{
  17899. useInstances: boolean;
  17900. }>): Promise<void>;
  17901. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17902. private _prepareShadowDefines;
  17903. /**
  17904. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17905. * @param subMesh The submesh we want to render in the shadow map
  17906. * @param useInstances Defines wether will draw in the map using instances
  17907. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17908. * @returns true if ready otherwise, false
  17909. */
  17910. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17911. /**
  17912. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17913. * @param defines Defines of the material we want to update
  17914. * @param lightIndex Index of the light in the enabled light list of the material
  17915. */
  17916. prepareDefines(defines: any, lightIndex: number): void;
  17917. /**
  17918. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17919. * defined in the generator but impacting the effect).
  17920. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17921. * @param effect The effect we are binfing the information for
  17922. */
  17923. bindShadowLight(lightIndex: string, effect: Effect): void;
  17924. /**
  17925. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17926. * (eq to shadow prjection matrix * light transform matrix)
  17927. * @returns The transform matrix used to create the shadow map
  17928. */
  17929. getTransformMatrix(): Matrix;
  17930. /**
  17931. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17932. * Cube and 2D textures for instance.
  17933. */
  17934. recreateShadowMap(): void;
  17935. protected _disposeBlurPostProcesses(): void;
  17936. protected _disposeRTTandPostProcesses(): void;
  17937. /**
  17938. * Disposes the ShadowGenerator.
  17939. * Returns nothing.
  17940. */
  17941. dispose(): void;
  17942. /**
  17943. * Serializes the shadow generator setup to a json object.
  17944. * @returns The serialized JSON object
  17945. */
  17946. serialize(): any;
  17947. /**
  17948. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17949. * @param parsedShadowGenerator The JSON object to parse
  17950. * @param scene The scene to create the shadow map for
  17951. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17952. * @returns The parsed shadow generator
  17953. */
  17954. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17955. }
  17956. }
  17957. declare module BABYLON {
  17958. /**
  17959. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17960. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17961. * 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.
  17962. */
  17963. export abstract class Light extends Node {
  17964. /**
  17965. * Falloff Default: light is falling off following the material specification:
  17966. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17967. */
  17968. static readonly FALLOFF_DEFAULT: number;
  17969. /**
  17970. * Falloff Physical: light is falling off following the inverse squared distance law.
  17971. */
  17972. static readonly FALLOFF_PHYSICAL: number;
  17973. /**
  17974. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17975. * to enhance interoperability with other engines.
  17976. */
  17977. static readonly FALLOFF_GLTF: number;
  17978. /**
  17979. * Falloff Standard: light is falling off like in the standard material
  17980. * to enhance interoperability with other materials.
  17981. */
  17982. static readonly FALLOFF_STANDARD: number;
  17983. /**
  17984. * If every light affecting the material is in this lightmapMode,
  17985. * material.lightmapTexture adds or multiplies
  17986. * (depends on material.useLightmapAsShadowmap)
  17987. * after every other light calculations.
  17988. */
  17989. static readonly LIGHTMAP_DEFAULT: number;
  17990. /**
  17991. * material.lightmapTexture as only diffuse lighting from this light
  17992. * adds only specular lighting from this light
  17993. * adds dynamic shadows
  17994. */
  17995. static readonly LIGHTMAP_SPECULAR: number;
  17996. /**
  17997. * material.lightmapTexture as only lighting
  17998. * no light calculation from this light
  17999. * only adds dynamic shadows from this light
  18000. */
  18001. static readonly LIGHTMAP_SHADOWSONLY: number;
  18002. /**
  18003. * Each light type uses the default quantity according to its type:
  18004. * point/spot lights use luminous intensity
  18005. * directional lights use illuminance
  18006. */
  18007. static readonly INTENSITYMODE_AUTOMATIC: number;
  18008. /**
  18009. * lumen (lm)
  18010. */
  18011. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18012. /**
  18013. * candela (lm/sr)
  18014. */
  18015. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18016. /**
  18017. * lux (lm/m^2)
  18018. */
  18019. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18020. /**
  18021. * nit (cd/m^2)
  18022. */
  18023. static readonly INTENSITYMODE_LUMINANCE: number;
  18024. /**
  18025. * Light type const id of the point light.
  18026. */
  18027. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18028. /**
  18029. * Light type const id of the directional light.
  18030. */
  18031. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18032. /**
  18033. * Light type const id of the spot light.
  18034. */
  18035. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18036. /**
  18037. * Light type const id of the hemispheric light.
  18038. */
  18039. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18040. /**
  18041. * Diffuse gives the basic color to an object.
  18042. */
  18043. diffuse: Color3;
  18044. /**
  18045. * Specular produces a highlight color on an object.
  18046. * Note: This is note affecting PBR materials.
  18047. */
  18048. specular: Color3;
  18049. /**
  18050. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18051. * falling off base on range or angle.
  18052. * This can be set to any values in Light.FALLOFF_x.
  18053. *
  18054. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18055. * other types of materials.
  18056. */
  18057. falloffType: number;
  18058. /**
  18059. * Strength of the light.
  18060. * Note: By default it is define in the framework own unit.
  18061. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18062. */
  18063. intensity: number;
  18064. private _range;
  18065. protected _inverseSquaredRange: number;
  18066. /**
  18067. * Defines how far from the source the light is impacting in scene units.
  18068. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18069. */
  18070. get range(): number;
  18071. /**
  18072. * Defines how far from the source the light is impacting in scene units.
  18073. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18074. */
  18075. set range(value: number);
  18076. /**
  18077. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18078. * of light.
  18079. */
  18080. private _photometricScale;
  18081. private _intensityMode;
  18082. /**
  18083. * Gets the photometric scale used to interpret the intensity.
  18084. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18085. */
  18086. get intensityMode(): number;
  18087. /**
  18088. * Sets the photometric scale used to interpret the intensity.
  18089. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18090. */
  18091. set intensityMode(value: number);
  18092. private _radius;
  18093. /**
  18094. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18095. */
  18096. get radius(): number;
  18097. /**
  18098. * sets the light radius used by PBR Materials to simulate soft area lights.
  18099. */
  18100. set radius(value: number);
  18101. private _renderPriority;
  18102. /**
  18103. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18104. * exceeding the number allowed of the materials.
  18105. */
  18106. renderPriority: number;
  18107. private _shadowEnabled;
  18108. /**
  18109. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18110. * the current shadow generator.
  18111. */
  18112. get shadowEnabled(): boolean;
  18113. /**
  18114. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18115. * the current shadow generator.
  18116. */
  18117. set shadowEnabled(value: boolean);
  18118. private _includedOnlyMeshes;
  18119. /**
  18120. * Gets the only meshes impacted by this light.
  18121. */
  18122. get includedOnlyMeshes(): AbstractMesh[];
  18123. /**
  18124. * Sets the only meshes impacted by this light.
  18125. */
  18126. set includedOnlyMeshes(value: AbstractMesh[]);
  18127. private _excludedMeshes;
  18128. /**
  18129. * Gets the meshes not impacted by this light.
  18130. */
  18131. get excludedMeshes(): AbstractMesh[];
  18132. /**
  18133. * Sets the meshes not impacted by this light.
  18134. */
  18135. set excludedMeshes(value: AbstractMesh[]);
  18136. private _excludeWithLayerMask;
  18137. /**
  18138. * Gets the layer id use to find what meshes are not impacted by the light.
  18139. * Inactive if 0
  18140. */
  18141. get excludeWithLayerMask(): number;
  18142. /**
  18143. * Sets the layer id use to find what meshes are not impacted by the light.
  18144. * Inactive if 0
  18145. */
  18146. set excludeWithLayerMask(value: number);
  18147. private _includeOnlyWithLayerMask;
  18148. /**
  18149. * Gets the layer id use to find what meshes are impacted by the light.
  18150. * Inactive if 0
  18151. */
  18152. get includeOnlyWithLayerMask(): number;
  18153. /**
  18154. * Sets the layer id use to find what meshes are impacted by the light.
  18155. * Inactive if 0
  18156. */
  18157. set includeOnlyWithLayerMask(value: number);
  18158. private _lightmapMode;
  18159. /**
  18160. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18161. */
  18162. get lightmapMode(): number;
  18163. /**
  18164. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18165. */
  18166. set lightmapMode(value: number);
  18167. /**
  18168. * Shadow generator associted to the light.
  18169. * @hidden Internal use only.
  18170. */
  18171. _shadowGenerator: Nullable<IShadowGenerator>;
  18172. /**
  18173. * @hidden Internal use only.
  18174. */
  18175. _excludedMeshesIds: string[];
  18176. /**
  18177. * @hidden Internal use only.
  18178. */
  18179. _includedOnlyMeshesIds: string[];
  18180. /**
  18181. * The current light unifom buffer.
  18182. * @hidden Internal use only.
  18183. */
  18184. _uniformBuffer: UniformBuffer;
  18185. /** @hidden */
  18186. _renderId: number;
  18187. /**
  18188. * Creates a Light object in the scene.
  18189. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18190. * @param name The firendly name of the light
  18191. * @param scene The scene the light belongs too
  18192. */
  18193. constructor(name: string, scene: Scene);
  18194. protected abstract _buildUniformLayout(): void;
  18195. /**
  18196. * Sets the passed Effect "effect" with the Light information.
  18197. * @param effect The effect to update
  18198. * @param lightIndex The index of the light in the effect to update
  18199. * @returns The light
  18200. */
  18201. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18202. /**
  18203. * Sets the passed Effect "effect" with the Light textures.
  18204. * @param effect The effect to update
  18205. * @param lightIndex The index of the light in the effect to update
  18206. * @returns The light
  18207. */
  18208. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18209. /**
  18210. * Binds the lights information from the scene to the effect for the given mesh.
  18211. * @param lightIndex Light index
  18212. * @param scene The scene where the light belongs to
  18213. * @param effect The effect we are binding the data to
  18214. * @param useSpecular Defines if specular is supported
  18215. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18216. */
  18217. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18218. /**
  18219. * Sets the passed Effect "effect" with the Light information.
  18220. * @param effect The effect to update
  18221. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18222. * @returns The light
  18223. */
  18224. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18225. /**
  18226. * Returns the string "Light".
  18227. * @returns the class name
  18228. */
  18229. getClassName(): string;
  18230. /** @hidden */
  18231. readonly _isLight: boolean;
  18232. /**
  18233. * Converts the light information to a readable string for debug purpose.
  18234. * @param fullDetails Supports for multiple levels of logging within scene loading
  18235. * @returns the human readable light info
  18236. */
  18237. toString(fullDetails?: boolean): string;
  18238. /** @hidden */
  18239. protected _syncParentEnabledState(): void;
  18240. /**
  18241. * Set the enabled state of this node.
  18242. * @param value - the new enabled state
  18243. */
  18244. setEnabled(value: boolean): void;
  18245. /**
  18246. * Returns the Light associated shadow generator if any.
  18247. * @return the associated shadow generator.
  18248. */
  18249. getShadowGenerator(): Nullable<IShadowGenerator>;
  18250. /**
  18251. * Returns a Vector3, the absolute light position in the World.
  18252. * @returns the world space position of the light
  18253. */
  18254. getAbsolutePosition(): Vector3;
  18255. /**
  18256. * Specifies if the light will affect the passed mesh.
  18257. * @param mesh The mesh to test against the light
  18258. * @return true the mesh is affected otherwise, false.
  18259. */
  18260. canAffectMesh(mesh: AbstractMesh): boolean;
  18261. /**
  18262. * Sort function to order lights for rendering.
  18263. * @param a First Light object to compare to second.
  18264. * @param b Second Light object to compare first.
  18265. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18266. */
  18267. static CompareLightsPriority(a: Light, b: Light): number;
  18268. /**
  18269. * Releases resources associated with this node.
  18270. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18271. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18272. */
  18273. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18274. /**
  18275. * Returns the light type ID (integer).
  18276. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18277. */
  18278. getTypeID(): number;
  18279. /**
  18280. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18281. * @returns the scaled intensity in intensity mode unit
  18282. */
  18283. getScaledIntensity(): number;
  18284. /**
  18285. * Returns a new Light object, named "name", from the current one.
  18286. * @param name The name of the cloned light
  18287. * @param newParent The parent of this light, if it has one
  18288. * @returns the new created light
  18289. */
  18290. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18291. /**
  18292. * Serializes the current light into a Serialization object.
  18293. * @returns the serialized object.
  18294. */
  18295. serialize(): any;
  18296. /**
  18297. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18298. * This new light is named "name" and added to the passed scene.
  18299. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18300. * @param name The friendly name of the light
  18301. * @param scene The scene the new light will belong to
  18302. * @returns the constructor function
  18303. */
  18304. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18305. /**
  18306. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18307. * @param parsedLight The JSON representation of the light
  18308. * @param scene The scene to create the parsed light in
  18309. * @returns the created light after parsing
  18310. */
  18311. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18312. private _hookArrayForExcluded;
  18313. private _hookArrayForIncludedOnly;
  18314. private _resyncMeshes;
  18315. /**
  18316. * Forces the meshes to update their light related information in their rendering used effects
  18317. * @hidden Internal Use Only
  18318. */
  18319. _markMeshesAsLightDirty(): void;
  18320. /**
  18321. * Recomputes the cached photometric scale if needed.
  18322. */
  18323. private _computePhotometricScale;
  18324. /**
  18325. * Returns the Photometric Scale according to the light type and intensity mode.
  18326. */
  18327. private _getPhotometricScale;
  18328. /**
  18329. * Reorder the light in the scene according to their defined priority.
  18330. * @hidden Internal Use Only
  18331. */
  18332. _reorderLightsInScene(): void;
  18333. /**
  18334. * Prepares the list of defines specific to the light type.
  18335. * @param defines the list of defines
  18336. * @param lightIndex defines the index of the light for the effect
  18337. */
  18338. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18339. }
  18340. }
  18341. declare module BABYLON {
  18342. /**
  18343. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18344. * This is the base of the follow, arc rotate cameras and Free camera
  18345. * @see https://doc.babylonjs.com/features/cameras
  18346. */
  18347. export class TargetCamera extends Camera {
  18348. private static _RigCamTransformMatrix;
  18349. private static _TargetTransformMatrix;
  18350. private static _TargetFocalPoint;
  18351. private _tmpUpVector;
  18352. private _tmpTargetVector;
  18353. /**
  18354. * Define the current direction the camera is moving to
  18355. */
  18356. cameraDirection: Vector3;
  18357. /**
  18358. * Define the current rotation the camera is rotating to
  18359. */
  18360. cameraRotation: Vector2;
  18361. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18362. ignoreParentScaling: boolean;
  18363. /**
  18364. * When set, the up vector of the camera will be updated by the rotation of the camera
  18365. */
  18366. updateUpVectorFromRotation: boolean;
  18367. private _tmpQuaternion;
  18368. /**
  18369. * Define the current rotation of the camera
  18370. */
  18371. rotation: Vector3;
  18372. /**
  18373. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18374. */
  18375. rotationQuaternion: Quaternion;
  18376. /**
  18377. * Define the current speed of the camera
  18378. */
  18379. speed: number;
  18380. /**
  18381. * Add constraint to the camera to prevent it to move freely in all directions and
  18382. * around all axis.
  18383. */
  18384. noRotationConstraint: boolean;
  18385. /**
  18386. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18387. * panning
  18388. */
  18389. invertRotation: boolean;
  18390. /**
  18391. * Speed multiplier for inverse camera panning
  18392. */
  18393. inverseRotationSpeed: number;
  18394. /**
  18395. * Define the current target of the camera as an object or a position.
  18396. */
  18397. lockedTarget: any;
  18398. /** @hidden */
  18399. _currentTarget: Vector3;
  18400. /** @hidden */
  18401. _initialFocalDistance: number;
  18402. /** @hidden */
  18403. _viewMatrix: Matrix;
  18404. /** @hidden */
  18405. _camMatrix: Matrix;
  18406. /** @hidden */
  18407. _cameraTransformMatrix: Matrix;
  18408. /** @hidden */
  18409. _cameraRotationMatrix: Matrix;
  18410. /** @hidden */
  18411. _referencePoint: Vector3;
  18412. /** @hidden */
  18413. _transformedReferencePoint: Vector3;
  18414. /** @hidden */
  18415. _reset: () => void;
  18416. private _defaultUp;
  18417. /**
  18418. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18419. * This is the base of the follow, arc rotate cameras and Free camera
  18420. * @see https://doc.babylonjs.com/features/cameras
  18421. * @param name Defines the name of the camera in the scene
  18422. * @param position Defines the start position of the camera in the scene
  18423. * @param scene Defines the scene the camera belongs to
  18424. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18425. */
  18426. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18427. /**
  18428. * Gets the position in front of the camera at a given distance.
  18429. * @param distance The distance from the camera we want the position to be
  18430. * @returns the position
  18431. */
  18432. getFrontPosition(distance: number): Vector3;
  18433. /** @hidden */
  18434. _getLockedTargetPosition(): Nullable<Vector3>;
  18435. private _storedPosition;
  18436. private _storedRotation;
  18437. private _storedRotationQuaternion;
  18438. /**
  18439. * Store current camera state of the camera (fov, position, rotation, etc..)
  18440. * @returns the camera
  18441. */
  18442. storeState(): Camera;
  18443. /**
  18444. * Restored camera state. You must call storeState() first
  18445. * @returns whether it was successful or not
  18446. * @hidden
  18447. */
  18448. _restoreStateValues(): boolean;
  18449. /** @hidden */
  18450. _initCache(): void;
  18451. /** @hidden */
  18452. _updateCache(ignoreParentClass?: boolean): void;
  18453. /** @hidden */
  18454. _isSynchronizedViewMatrix(): boolean;
  18455. /** @hidden */
  18456. _computeLocalCameraSpeed(): number;
  18457. /**
  18458. * Defines the target the camera should look at.
  18459. * @param target Defines the new target as a Vector or a mesh
  18460. */
  18461. setTarget(target: Vector3): void;
  18462. /**
  18463. * Defines the target point of the camera.
  18464. * The camera looks towards it form the radius distance.
  18465. */
  18466. get target(): Vector3;
  18467. set target(value: Vector3);
  18468. /**
  18469. * Return the current target position of the camera. This value is expressed in local space.
  18470. * @returns the target position
  18471. */
  18472. getTarget(): Vector3;
  18473. /** @hidden */
  18474. _decideIfNeedsToMove(): boolean;
  18475. /** @hidden */
  18476. _updatePosition(): void;
  18477. /** @hidden */
  18478. _checkInputs(): void;
  18479. protected _updateCameraRotationMatrix(): void;
  18480. /**
  18481. * 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)
  18482. * @returns the current camera
  18483. */
  18484. private _rotateUpVectorWithCameraRotationMatrix;
  18485. private _cachedRotationZ;
  18486. private _cachedQuaternionRotationZ;
  18487. /** @hidden */
  18488. _getViewMatrix(): Matrix;
  18489. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18490. /**
  18491. * @hidden
  18492. */
  18493. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18494. /**
  18495. * @hidden
  18496. */
  18497. _updateRigCameras(): void;
  18498. private _getRigCamPositionAndTarget;
  18499. /**
  18500. * Gets the current object class name.
  18501. * @return the class name
  18502. */
  18503. getClassName(): string;
  18504. }
  18505. }
  18506. declare module BABYLON {
  18507. /**
  18508. * Gather the list of keyboard event types as constants.
  18509. */
  18510. export class KeyboardEventTypes {
  18511. /**
  18512. * The keydown event is fired when a key becomes active (pressed).
  18513. */
  18514. static readonly KEYDOWN: number;
  18515. /**
  18516. * The keyup event is fired when a key has been released.
  18517. */
  18518. static readonly KEYUP: number;
  18519. }
  18520. /**
  18521. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18522. */
  18523. export class KeyboardInfo {
  18524. /**
  18525. * Defines the type of event (KeyboardEventTypes)
  18526. */
  18527. type: number;
  18528. /**
  18529. * Defines the related dom event
  18530. */
  18531. event: KeyboardEvent;
  18532. /**
  18533. * Instantiates a new keyboard info.
  18534. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18535. * @param type Defines the type of event (KeyboardEventTypes)
  18536. * @param event Defines the related dom event
  18537. */
  18538. constructor(
  18539. /**
  18540. * Defines the type of event (KeyboardEventTypes)
  18541. */
  18542. type: number,
  18543. /**
  18544. * Defines the related dom event
  18545. */
  18546. event: KeyboardEvent);
  18547. }
  18548. /**
  18549. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18550. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18551. */
  18552. export class KeyboardInfoPre extends KeyboardInfo {
  18553. /**
  18554. * Defines the type of event (KeyboardEventTypes)
  18555. */
  18556. type: number;
  18557. /**
  18558. * Defines the related dom event
  18559. */
  18560. event: KeyboardEvent;
  18561. /**
  18562. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18563. */
  18564. skipOnPointerObservable: boolean;
  18565. /**
  18566. * Instantiates a new keyboard pre info.
  18567. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18568. * @param type Defines the type of event (KeyboardEventTypes)
  18569. * @param event Defines the related dom event
  18570. */
  18571. constructor(
  18572. /**
  18573. * Defines the type of event (KeyboardEventTypes)
  18574. */
  18575. type: number,
  18576. /**
  18577. * Defines the related dom event
  18578. */
  18579. event: KeyboardEvent);
  18580. }
  18581. }
  18582. declare module BABYLON {
  18583. /**
  18584. * Manage the keyboard inputs to control the movement of a free camera.
  18585. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18586. */
  18587. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18588. /**
  18589. * Defines the camera the input is attached to.
  18590. */
  18591. camera: FreeCamera;
  18592. /**
  18593. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18594. */
  18595. keysUp: number[];
  18596. /**
  18597. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18598. */
  18599. keysUpward: number[];
  18600. /**
  18601. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18602. */
  18603. keysDown: number[];
  18604. /**
  18605. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18606. */
  18607. keysDownward: number[];
  18608. /**
  18609. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18610. */
  18611. keysLeft: number[];
  18612. /**
  18613. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18614. */
  18615. keysRight: number[];
  18616. private _keys;
  18617. private _onCanvasBlurObserver;
  18618. private _onKeyboardObserver;
  18619. private _engine;
  18620. private _scene;
  18621. /**
  18622. * Attach the input controls to a specific dom element to get the input from.
  18623. * @param element Defines the element the controls should be listened from
  18624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18625. */
  18626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18627. /**
  18628. * Detach the current controls from the specified dom element.
  18629. * @param element Defines the element to stop listening the inputs from
  18630. */
  18631. detachControl(element: Nullable<HTMLElement>): void;
  18632. /**
  18633. * Update the current camera state depending on the inputs that have been used this frame.
  18634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18635. */
  18636. checkInputs(): void;
  18637. /**
  18638. * Gets the class name of the current intput.
  18639. * @returns the class name
  18640. */
  18641. getClassName(): string;
  18642. /** @hidden */
  18643. _onLostFocus(): void;
  18644. /**
  18645. * Get the friendly name associated with the input class.
  18646. * @returns the input friendly name
  18647. */
  18648. getSimpleName(): string;
  18649. }
  18650. }
  18651. declare module BABYLON {
  18652. /**
  18653. * Gather the list of pointer event types as constants.
  18654. */
  18655. export class PointerEventTypes {
  18656. /**
  18657. * 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.
  18658. */
  18659. static readonly POINTERDOWN: number;
  18660. /**
  18661. * The pointerup event is fired when a pointer is no longer active.
  18662. */
  18663. static readonly POINTERUP: number;
  18664. /**
  18665. * The pointermove event is fired when a pointer changes coordinates.
  18666. */
  18667. static readonly POINTERMOVE: number;
  18668. /**
  18669. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18670. */
  18671. static readonly POINTERWHEEL: number;
  18672. /**
  18673. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18674. */
  18675. static readonly POINTERPICK: number;
  18676. /**
  18677. * The pointertap event is fired when a the object has been touched and released without drag.
  18678. */
  18679. static readonly POINTERTAP: number;
  18680. /**
  18681. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18682. */
  18683. static readonly POINTERDOUBLETAP: number;
  18684. }
  18685. /**
  18686. * Base class of pointer info types.
  18687. */
  18688. export class PointerInfoBase {
  18689. /**
  18690. * Defines the type of event (PointerEventTypes)
  18691. */
  18692. type: number;
  18693. /**
  18694. * Defines the related dom event
  18695. */
  18696. event: PointerEvent | MouseWheelEvent;
  18697. /**
  18698. * Instantiates the base class of pointers info.
  18699. * @param type Defines the type of event (PointerEventTypes)
  18700. * @param event Defines the related dom event
  18701. */
  18702. constructor(
  18703. /**
  18704. * Defines the type of event (PointerEventTypes)
  18705. */
  18706. type: number,
  18707. /**
  18708. * Defines the related dom event
  18709. */
  18710. event: PointerEvent | MouseWheelEvent);
  18711. }
  18712. /**
  18713. * This class is used to store pointer related info for the onPrePointerObservable event.
  18714. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18715. */
  18716. export class PointerInfoPre extends PointerInfoBase {
  18717. /**
  18718. * Ray from a pointer if availible (eg. 6dof controller)
  18719. */
  18720. ray: Nullable<Ray>;
  18721. /**
  18722. * Defines the local position of the pointer on the canvas.
  18723. */
  18724. localPosition: Vector2;
  18725. /**
  18726. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18727. */
  18728. skipOnPointerObservable: boolean;
  18729. /**
  18730. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18731. * @param type Defines the type of event (PointerEventTypes)
  18732. * @param event Defines the related dom event
  18733. * @param localX Defines the local x coordinates of the pointer when the event occured
  18734. * @param localY Defines the local y coordinates of the pointer when the event occured
  18735. */
  18736. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18737. }
  18738. /**
  18739. * This type contains all the data related to a pointer event in Babylon.js.
  18740. * 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.
  18741. */
  18742. export class PointerInfo extends PointerInfoBase {
  18743. /**
  18744. * Defines the picking info associated to the info (if any)\
  18745. */
  18746. pickInfo: Nullable<PickingInfo>;
  18747. /**
  18748. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18749. * @param type Defines the type of event (PointerEventTypes)
  18750. * @param event Defines the related dom event
  18751. * @param pickInfo Defines the picking info associated to the info (if any)\
  18752. */
  18753. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18754. /**
  18755. * Defines the picking info associated to the info (if any)\
  18756. */
  18757. pickInfo: Nullable<PickingInfo>);
  18758. }
  18759. /**
  18760. * Data relating to a touch event on the screen.
  18761. */
  18762. export interface PointerTouch {
  18763. /**
  18764. * X coordinate of touch.
  18765. */
  18766. x: number;
  18767. /**
  18768. * Y coordinate of touch.
  18769. */
  18770. y: number;
  18771. /**
  18772. * Id of touch. Unique for each finger.
  18773. */
  18774. pointerId: number;
  18775. /**
  18776. * Event type passed from DOM.
  18777. */
  18778. type: any;
  18779. }
  18780. }
  18781. declare module BABYLON {
  18782. /**
  18783. * Manage the mouse inputs to control the movement of a free camera.
  18784. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18785. */
  18786. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18787. /**
  18788. * Define if touch is enabled in the mouse input
  18789. */
  18790. touchEnabled: boolean;
  18791. /**
  18792. * Defines the camera the input is attached to.
  18793. */
  18794. camera: FreeCamera;
  18795. /**
  18796. * Defines the buttons associated with the input to handle camera move.
  18797. */
  18798. buttons: number[];
  18799. /**
  18800. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18801. */
  18802. angularSensibility: number;
  18803. private _pointerInput;
  18804. private _onMouseMove;
  18805. private _observer;
  18806. private previousPosition;
  18807. /**
  18808. * Observable for when a pointer move event occurs containing the move offset
  18809. */
  18810. onPointerMovedObservable: Observable<{
  18811. offsetX: number;
  18812. offsetY: number;
  18813. }>;
  18814. /**
  18815. * @hidden
  18816. * If the camera should be rotated automatically based on pointer movement
  18817. */
  18818. _allowCameraRotation: boolean;
  18819. /**
  18820. * Manage the mouse inputs to control the movement of a free camera.
  18821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18822. * @param touchEnabled Defines if touch is enabled or not
  18823. */
  18824. constructor(
  18825. /**
  18826. * Define if touch is enabled in the mouse input
  18827. */
  18828. touchEnabled?: boolean);
  18829. /**
  18830. * Attach the input controls to a specific dom element to get the input from.
  18831. * @param element Defines the element the controls should be listened from
  18832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18833. */
  18834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18835. /**
  18836. * Called on JS contextmenu event.
  18837. * Override this method to provide functionality.
  18838. */
  18839. protected onContextMenu(evt: PointerEvent): void;
  18840. /**
  18841. * Detach the current controls from the specified dom element.
  18842. * @param element Defines the element to stop listening the inputs from
  18843. */
  18844. detachControl(element: Nullable<HTMLElement>): void;
  18845. /**
  18846. * Gets the class name of the current intput.
  18847. * @returns the class name
  18848. */
  18849. getClassName(): string;
  18850. /**
  18851. * Get the friendly name associated with the input class.
  18852. * @returns the input friendly name
  18853. */
  18854. getSimpleName(): string;
  18855. }
  18856. }
  18857. declare module BABYLON {
  18858. /**
  18859. * Manage the touch inputs to control the movement of a free camera.
  18860. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18861. */
  18862. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18863. /**
  18864. * Define if mouse events can be treated as touch events
  18865. */
  18866. allowMouse: boolean;
  18867. /**
  18868. * Defines the camera the input is attached to.
  18869. */
  18870. camera: FreeCamera;
  18871. /**
  18872. * Defines the touch sensibility for rotation.
  18873. * The higher the faster.
  18874. */
  18875. touchAngularSensibility: number;
  18876. /**
  18877. * Defines the touch sensibility for move.
  18878. * The higher the faster.
  18879. */
  18880. touchMoveSensibility: number;
  18881. private _offsetX;
  18882. private _offsetY;
  18883. private _pointerPressed;
  18884. private _pointerInput;
  18885. private _observer;
  18886. private _onLostFocus;
  18887. /**
  18888. * Manage the touch inputs to control the movement of a free camera.
  18889. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18890. * @param allowMouse Defines if mouse events can be treated as touch events
  18891. */
  18892. constructor(
  18893. /**
  18894. * Define if mouse events can be treated as touch events
  18895. */
  18896. allowMouse?: boolean);
  18897. /**
  18898. * Attach the input controls to a specific dom element to get the input from.
  18899. * @param element Defines the element the controls should be listened from
  18900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18901. */
  18902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18903. /**
  18904. * Detach the current controls from the specified dom element.
  18905. * @param element Defines the element to stop listening the inputs from
  18906. */
  18907. detachControl(element: Nullable<HTMLElement>): void;
  18908. /**
  18909. * Update the current camera state depending on the inputs that have been used this frame.
  18910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18911. */
  18912. checkInputs(): void;
  18913. /**
  18914. * Gets the class name of the current intput.
  18915. * @returns the class name
  18916. */
  18917. getClassName(): string;
  18918. /**
  18919. * Get the friendly name associated with the input class.
  18920. * @returns the input friendly name
  18921. */
  18922. getSimpleName(): string;
  18923. }
  18924. }
  18925. declare module BABYLON {
  18926. /**
  18927. * Default Inputs manager for the FreeCamera.
  18928. * It groups all the default supported inputs for ease of use.
  18929. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18930. */
  18931. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18932. /**
  18933. * @hidden
  18934. */
  18935. _mouseInput: Nullable<FreeCameraMouseInput>;
  18936. /**
  18937. * Instantiates a new FreeCameraInputsManager.
  18938. * @param camera Defines the camera the inputs belong to
  18939. */
  18940. constructor(camera: FreeCamera);
  18941. /**
  18942. * Add keyboard input support to the input manager.
  18943. * @returns the current input manager
  18944. */
  18945. addKeyboard(): FreeCameraInputsManager;
  18946. /**
  18947. * Add mouse input support to the input manager.
  18948. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18949. * @returns the current input manager
  18950. */
  18951. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18952. /**
  18953. * Removes the mouse input support from the manager
  18954. * @returns the current input manager
  18955. */
  18956. removeMouse(): FreeCameraInputsManager;
  18957. /**
  18958. * Add touch input support to the input manager.
  18959. * @returns the current input manager
  18960. */
  18961. addTouch(): FreeCameraInputsManager;
  18962. /**
  18963. * Remove all attached input methods from a camera
  18964. */
  18965. clear(): void;
  18966. }
  18967. }
  18968. declare module BABYLON {
  18969. /**
  18970. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18971. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18972. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18973. */
  18974. export class FreeCamera extends TargetCamera {
  18975. /**
  18976. * Define the collision ellipsoid of the camera.
  18977. * This is helpful to simulate a camera body like the player body around the camera
  18978. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18979. */
  18980. ellipsoid: Vector3;
  18981. /**
  18982. * Define an offset for the position of the ellipsoid around the camera.
  18983. * This can be helpful to determine the center of the body near the gravity center of the body
  18984. * instead of its head.
  18985. */
  18986. ellipsoidOffset: Vector3;
  18987. /**
  18988. * Enable or disable collisions of the camera with the rest of the scene objects.
  18989. */
  18990. checkCollisions: boolean;
  18991. /**
  18992. * Enable or disable gravity on the camera.
  18993. */
  18994. applyGravity: boolean;
  18995. /**
  18996. * Define the input manager associated to the camera.
  18997. */
  18998. inputs: FreeCameraInputsManager;
  18999. /**
  19000. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19001. * Higher values reduce sensitivity.
  19002. */
  19003. get angularSensibility(): number;
  19004. /**
  19005. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19006. * Higher values reduce sensitivity.
  19007. */
  19008. set angularSensibility(value: number);
  19009. /**
  19010. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19011. */
  19012. get keysUp(): number[];
  19013. set keysUp(value: number[]);
  19014. /**
  19015. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19016. */
  19017. get keysUpward(): number[];
  19018. set keysUpward(value: number[]);
  19019. /**
  19020. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19021. */
  19022. get keysDown(): number[];
  19023. set keysDown(value: number[]);
  19024. /**
  19025. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19026. */
  19027. get keysDownward(): number[];
  19028. set keysDownward(value: number[]);
  19029. /**
  19030. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19031. */
  19032. get keysLeft(): number[];
  19033. set keysLeft(value: number[]);
  19034. /**
  19035. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19036. */
  19037. get keysRight(): number[];
  19038. set keysRight(value: number[]);
  19039. /**
  19040. * Event raised when the camera collide with a mesh in the scene.
  19041. */
  19042. onCollide: (collidedMesh: AbstractMesh) => void;
  19043. private _collider;
  19044. private _needMoveForGravity;
  19045. private _oldPosition;
  19046. private _diffPosition;
  19047. private _newPosition;
  19048. /** @hidden */
  19049. _localDirection: Vector3;
  19050. /** @hidden */
  19051. _transformedDirection: Vector3;
  19052. /**
  19053. * Instantiates a Free Camera.
  19054. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19055. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19056. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19057. * @param name Define the name of the camera in the scene
  19058. * @param position Define the start position of the camera in the scene
  19059. * @param scene Define the scene the camera belongs to
  19060. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19061. */
  19062. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19063. /**
  19064. * Attached controls to the current camera.
  19065. * @param element Defines the element the controls should be listened from
  19066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19067. */
  19068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19069. /**
  19070. * Detach the current controls from the camera.
  19071. * The camera will stop reacting to inputs.
  19072. * @param element Defines the element to stop listening the inputs from
  19073. */
  19074. detachControl(element: HTMLElement): void;
  19075. private _collisionMask;
  19076. /**
  19077. * Define a collision mask to limit the list of object the camera can collide with
  19078. */
  19079. get collisionMask(): number;
  19080. set collisionMask(mask: number);
  19081. /** @hidden */
  19082. _collideWithWorld(displacement: Vector3): void;
  19083. private _onCollisionPositionChange;
  19084. /** @hidden */
  19085. _checkInputs(): void;
  19086. /** @hidden */
  19087. _decideIfNeedsToMove(): boolean;
  19088. /** @hidden */
  19089. _updatePosition(): void;
  19090. /**
  19091. * Destroy the camera and release the current resources hold by it.
  19092. */
  19093. dispose(): void;
  19094. /**
  19095. * Gets the current object class name.
  19096. * @return the class name
  19097. */
  19098. getClassName(): string;
  19099. }
  19100. }
  19101. declare module BABYLON {
  19102. /**
  19103. * Represents a gamepad control stick position
  19104. */
  19105. export class StickValues {
  19106. /**
  19107. * The x component of the control stick
  19108. */
  19109. x: number;
  19110. /**
  19111. * The y component of the control stick
  19112. */
  19113. y: number;
  19114. /**
  19115. * Initializes the gamepad x and y control stick values
  19116. * @param x The x component of the gamepad control stick value
  19117. * @param y The y component of the gamepad control stick value
  19118. */
  19119. constructor(
  19120. /**
  19121. * The x component of the control stick
  19122. */
  19123. x: number,
  19124. /**
  19125. * The y component of the control stick
  19126. */
  19127. y: number);
  19128. }
  19129. /**
  19130. * An interface which manages callbacks for gamepad button changes
  19131. */
  19132. export interface GamepadButtonChanges {
  19133. /**
  19134. * Called when a gamepad has been changed
  19135. */
  19136. changed: boolean;
  19137. /**
  19138. * Called when a gamepad press event has been triggered
  19139. */
  19140. pressChanged: boolean;
  19141. /**
  19142. * Called when a touch event has been triggered
  19143. */
  19144. touchChanged: boolean;
  19145. /**
  19146. * Called when a value has changed
  19147. */
  19148. valueChanged: boolean;
  19149. }
  19150. /**
  19151. * Represents a gamepad
  19152. */
  19153. export class Gamepad {
  19154. /**
  19155. * The id of the gamepad
  19156. */
  19157. id: string;
  19158. /**
  19159. * The index of the gamepad
  19160. */
  19161. index: number;
  19162. /**
  19163. * The browser gamepad
  19164. */
  19165. browserGamepad: any;
  19166. /**
  19167. * Specifies what type of gamepad this represents
  19168. */
  19169. type: number;
  19170. private _leftStick;
  19171. private _rightStick;
  19172. /** @hidden */
  19173. _isConnected: boolean;
  19174. private _leftStickAxisX;
  19175. private _leftStickAxisY;
  19176. private _rightStickAxisX;
  19177. private _rightStickAxisY;
  19178. /**
  19179. * Triggered when the left control stick has been changed
  19180. */
  19181. private _onleftstickchanged;
  19182. /**
  19183. * Triggered when the right control stick has been changed
  19184. */
  19185. private _onrightstickchanged;
  19186. /**
  19187. * Represents a gamepad controller
  19188. */
  19189. static GAMEPAD: number;
  19190. /**
  19191. * Represents a generic controller
  19192. */
  19193. static GENERIC: number;
  19194. /**
  19195. * Represents an XBox controller
  19196. */
  19197. static XBOX: number;
  19198. /**
  19199. * Represents a pose-enabled controller
  19200. */
  19201. static POSE_ENABLED: number;
  19202. /**
  19203. * Represents an Dual Shock controller
  19204. */
  19205. static DUALSHOCK: number;
  19206. /**
  19207. * Specifies whether the left control stick should be Y-inverted
  19208. */
  19209. protected _invertLeftStickY: boolean;
  19210. /**
  19211. * Specifies if the gamepad has been connected
  19212. */
  19213. get isConnected(): boolean;
  19214. /**
  19215. * Initializes the gamepad
  19216. * @param id The id of the gamepad
  19217. * @param index The index of the gamepad
  19218. * @param browserGamepad The browser gamepad
  19219. * @param leftStickX The x component of the left joystick
  19220. * @param leftStickY The y component of the left joystick
  19221. * @param rightStickX The x component of the right joystick
  19222. * @param rightStickY The y component of the right joystick
  19223. */
  19224. constructor(
  19225. /**
  19226. * The id of the gamepad
  19227. */
  19228. id: string,
  19229. /**
  19230. * The index of the gamepad
  19231. */
  19232. index: number,
  19233. /**
  19234. * The browser gamepad
  19235. */
  19236. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19237. /**
  19238. * Callback triggered when the left joystick has changed
  19239. * @param callback
  19240. */
  19241. onleftstickchanged(callback: (values: StickValues) => void): void;
  19242. /**
  19243. * Callback triggered when the right joystick has changed
  19244. * @param callback
  19245. */
  19246. onrightstickchanged(callback: (values: StickValues) => void): void;
  19247. /**
  19248. * Gets the left joystick
  19249. */
  19250. get leftStick(): StickValues;
  19251. /**
  19252. * Sets the left joystick values
  19253. */
  19254. set leftStick(newValues: StickValues);
  19255. /**
  19256. * Gets the right joystick
  19257. */
  19258. get rightStick(): StickValues;
  19259. /**
  19260. * Sets the right joystick value
  19261. */
  19262. set rightStick(newValues: StickValues);
  19263. /**
  19264. * Updates the gamepad joystick positions
  19265. */
  19266. update(): void;
  19267. /**
  19268. * Disposes the gamepad
  19269. */
  19270. dispose(): void;
  19271. }
  19272. /**
  19273. * Represents a generic gamepad
  19274. */
  19275. export class GenericPad extends Gamepad {
  19276. private _buttons;
  19277. private _onbuttondown;
  19278. private _onbuttonup;
  19279. /**
  19280. * Observable triggered when a button has been pressed
  19281. */
  19282. onButtonDownObservable: Observable<number>;
  19283. /**
  19284. * Observable triggered when a button has been released
  19285. */
  19286. onButtonUpObservable: Observable<number>;
  19287. /**
  19288. * Callback triggered when a button has been pressed
  19289. * @param callback Called when a button has been pressed
  19290. */
  19291. onbuttondown(callback: (buttonPressed: number) => void): void;
  19292. /**
  19293. * Callback triggered when a button has been released
  19294. * @param callback Called when a button has been released
  19295. */
  19296. onbuttonup(callback: (buttonReleased: number) => void): void;
  19297. /**
  19298. * Initializes the generic gamepad
  19299. * @param id The id of the generic gamepad
  19300. * @param index The index of the generic gamepad
  19301. * @param browserGamepad The browser gamepad
  19302. */
  19303. constructor(id: string, index: number, browserGamepad: any);
  19304. private _setButtonValue;
  19305. /**
  19306. * Updates the generic gamepad
  19307. */
  19308. update(): void;
  19309. /**
  19310. * Disposes the generic gamepad
  19311. */
  19312. dispose(): void;
  19313. }
  19314. }
  19315. declare module BABYLON {
  19316. /**
  19317. * Defines the types of pose enabled controllers that are supported
  19318. */
  19319. export enum PoseEnabledControllerType {
  19320. /**
  19321. * HTC Vive
  19322. */
  19323. VIVE = 0,
  19324. /**
  19325. * Oculus Rift
  19326. */
  19327. OCULUS = 1,
  19328. /**
  19329. * Windows mixed reality
  19330. */
  19331. WINDOWS = 2,
  19332. /**
  19333. * Samsung gear VR
  19334. */
  19335. GEAR_VR = 3,
  19336. /**
  19337. * Google Daydream
  19338. */
  19339. DAYDREAM = 4,
  19340. /**
  19341. * Generic
  19342. */
  19343. GENERIC = 5
  19344. }
  19345. /**
  19346. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19347. */
  19348. export interface MutableGamepadButton {
  19349. /**
  19350. * Value of the button/trigger
  19351. */
  19352. value: number;
  19353. /**
  19354. * If the button/trigger is currently touched
  19355. */
  19356. touched: boolean;
  19357. /**
  19358. * If the button/trigger is currently pressed
  19359. */
  19360. pressed: boolean;
  19361. }
  19362. /**
  19363. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19364. * @hidden
  19365. */
  19366. export interface ExtendedGamepadButton extends GamepadButton {
  19367. /**
  19368. * If the button/trigger is currently pressed
  19369. */
  19370. readonly pressed: boolean;
  19371. /**
  19372. * If the button/trigger is currently touched
  19373. */
  19374. readonly touched: boolean;
  19375. /**
  19376. * Value of the button/trigger
  19377. */
  19378. readonly value: number;
  19379. }
  19380. /** @hidden */
  19381. export interface _GamePadFactory {
  19382. /**
  19383. * Returns whether or not the current gamepad can be created for this type of controller.
  19384. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19385. * @returns true if it can be created, otherwise false
  19386. */
  19387. canCreate(gamepadInfo: any): boolean;
  19388. /**
  19389. * Creates a new instance of the Gamepad.
  19390. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19391. * @returns the new gamepad instance
  19392. */
  19393. create(gamepadInfo: any): Gamepad;
  19394. }
  19395. /**
  19396. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19397. */
  19398. export class PoseEnabledControllerHelper {
  19399. /** @hidden */
  19400. static _ControllerFactories: _GamePadFactory[];
  19401. /** @hidden */
  19402. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19403. /**
  19404. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19405. * @param vrGamepad the gamepad to initialized
  19406. * @returns a vr controller of the type the gamepad identified as
  19407. */
  19408. static InitiateController(vrGamepad: any): Gamepad;
  19409. }
  19410. /**
  19411. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19412. */
  19413. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19414. /**
  19415. * If the controller is used in a webXR session
  19416. */
  19417. isXR: boolean;
  19418. private _deviceRoomPosition;
  19419. private _deviceRoomRotationQuaternion;
  19420. /**
  19421. * The device position in babylon space
  19422. */
  19423. devicePosition: Vector3;
  19424. /**
  19425. * The device rotation in babylon space
  19426. */
  19427. deviceRotationQuaternion: Quaternion;
  19428. /**
  19429. * The scale factor of the device in babylon space
  19430. */
  19431. deviceScaleFactor: number;
  19432. /**
  19433. * (Likely devicePosition should be used instead) The device position in its room space
  19434. */
  19435. position: Vector3;
  19436. /**
  19437. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19438. */
  19439. rotationQuaternion: Quaternion;
  19440. /**
  19441. * The type of controller (Eg. Windows mixed reality)
  19442. */
  19443. controllerType: PoseEnabledControllerType;
  19444. protected _calculatedPosition: Vector3;
  19445. private _calculatedRotation;
  19446. /**
  19447. * The raw pose from the device
  19448. */
  19449. rawPose: DevicePose;
  19450. private _trackPosition;
  19451. private _maxRotationDistFromHeadset;
  19452. private _draggedRoomRotation;
  19453. /**
  19454. * @hidden
  19455. */
  19456. _disableTrackPosition(fixedPosition: Vector3): void;
  19457. /**
  19458. * Internal, the mesh attached to the controller
  19459. * @hidden
  19460. */
  19461. _mesh: Nullable<AbstractMesh>;
  19462. private _poseControlledCamera;
  19463. private _leftHandSystemQuaternion;
  19464. /**
  19465. * Internal, matrix used to convert room space to babylon space
  19466. * @hidden
  19467. */
  19468. _deviceToWorld: Matrix;
  19469. /**
  19470. * Node to be used when casting a ray from the controller
  19471. * @hidden
  19472. */
  19473. _pointingPoseNode: Nullable<TransformNode>;
  19474. /**
  19475. * Name of the child mesh that can be used to cast a ray from the controller
  19476. */
  19477. static readonly POINTING_POSE: string;
  19478. /**
  19479. * Creates a new PoseEnabledController from a gamepad
  19480. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19481. */
  19482. constructor(browserGamepad: any);
  19483. private _workingMatrix;
  19484. /**
  19485. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19486. */
  19487. update(): void;
  19488. /**
  19489. * Updates only the pose device and mesh without doing any button event checking
  19490. */
  19491. protected _updatePoseAndMesh(): void;
  19492. /**
  19493. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19494. * @param poseData raw pose fromthe device
  19495. */
  19496. updateFromDevice(poseData: DevicePose): void;
  19497. /**
  19498. * @hidden
  19499. */
  19500. _meshAttachedObservable: Observable<AbstractMesh>;
  19501. /**
  19502. * Attaches a mesh to the controller
  19503. * @param mesh the mesh to be attached
  19504. */
  19505. attachToMesh(mesh: AbstractMesh): void;
  19506. /**
  19507. * Attaches the controllers mesh to a camera
  19508. * @param camera the camera the mesh should be attached to
  19509. */
  19510. attachToPoseControlledCamera(camera: TargetCamera): void;
  19511. /**
  19512. * Disposes of the controller
  19513. */
  19514. dispose(): void;
  19515. /**
  19516. * The mesh that is attached to the controller
  19517. */
  19518. get mesh(): Nullable<AbstractMesh>;
  19519. /**
  19520. * Gets the ray of the controller in the direction the controller is pointing
  19521. * @param length the length the resulting ray should be
  19522. * @returns a ray in the direction the controller is pointing
  19523. */
  19524. getForwardRay(length?: number): Ray;
  19525. }
  19526. }
  19527. declare module BABYLON {
  19528. /**
  19529. * Defines the WebVRController object that represents controllers tracked in 3D space
  19530. */
  19531. export abstract class WebVRController extends PoseEnabledController {
  19532. /**
  19533. * Internal, the default controller model for the controller
  19534. */
  19535. protected _defaultModel: Nullable<AbstractMesh>;
  19536. /**
  19537. * Fired when the trigger state has changed
  19538. */
  19539. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19540. /**
  19541. * Fired when the main button state has changed
  19542. */
  19543. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19544. /**
  19545. * Fired when the secondary button state has changed
  19546. */
  19547. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19548. /**
  19549. * Fired when the pad state has changed
  19550. */
  19551. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19552. /**
  19553. * Fired when controllers stick values have changed
  19554. */
  19555. onPadValuesChangedObservable: Observable<StickValues>;
  19556. /**
  19557. * Array of button availible on the controller
  19558. */
  19559. protected _buttons: Array<MutableGamepadButton>;
  19560. private _onButtonStateChange;
  19561. /**
  19562. * Fired when a controller button's state has changed
  19563. * @param callback the callback containing the button that was modified
  19564. */
  19565. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19566. /**
  19567. * X and Y axis corresponding to the controllers joystick
  19568. */
  19569. pad: StickValues;
  19570. /**
  19571. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19572. */
  19573. hand: string;
  19574. /**
  19575. * The default controller model for the controller
  19576. */
  19577. get defaultModel(): Nullable<AbstractMesh>;
  19578. /**
  19579. * Creates a new WebVRController from a gamepad
  19580. * @param vrGamepad the gamepad that the WebVRController should be created from
  19581. */
  19582. constructor(vrGamepad: any);
  19583. /**
  19584. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19585. */
  19586. update(): void;
  19587. /**
  19588. * Function to be called when a button is modified
  19589. */
  19590. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19591. /**
  19592. * Loads a mesh and attaches it to the controller
  19593. * @param scene the scene the mesh should be added to
  19594. * @param meshLoaded callback for when the mesh has been loaded
  19595. */
  19596. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19597. private _setButtonValue;
  19598. private _changes;
  19599. private _checkChanges;
  19600. /**
  19601. * Disposes of th webVRCOntroller
  19602. */
  19603. dispose(): void;
  19604. }
  19605. }
  19606. declare module BABYLON {
  19607. /**
  19608. * The HemisphericLight simulates the ambient environment light,
  19609. * so the passed direction is the light reflection direction, not the incoming direction.
  19610. */
  19611. export class HemisphericLight extends Light {
  19612. /**
  19613. * The groundColor is the light in the opposite direction to the one specified during creation.
  19614. * 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.
  19615. */
  19616. groundColor: Color3;
  19617. /**
  19618. * The light reflection direction, not the incoming direction.
  19619. */
  19620. direction: Vector3;
  19621. /**
  19622. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19623. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19624. * The HemisphericLight can't cast shadows.
  19625. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19626. * @param name The friendly name of the light
  19627. * @param direction The direction of the light reflection
  19628. * @param scene The scene the light belongs to
  19629. */
  19630. constructor(name: string, direction: Vector3, scene: Scene);
  19631. protected _buildUniformLayout(): void;
  19632. /**
  19633. * Returns the string "HemisphericLight".
  19634. * @return The class name
  19635. */
  19636. getClassName(): string;
  19637. /**
  19638. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19639. * Returns the updated direction.
  19640. * @param target The target the direction should point to
  19641. * @return The computed direction
  19642. */
  19643. setDirectionToTarget(target: Vector3): Vector3;
  19644. /**
  19645. * Returns the shadow generator associated to the light.
  19646. * @returns Always null for hemispheric lights because it does not support shadows.
  19647. */
  19648. getShadowGenerator(): Nullable<IShadowGenerator>;
  19649. /**
  19650. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19651. * @param effect The effect to update
  19652. * @param lightIndex The index of the light in the effect to update
  19653. * @returns The hemispheric light
  19654. */
  19655. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19656. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19657. /**
  19658. * Computes the world matrix of the node
  19659. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19660. * @param useWasUpdatedFlag defines a reserved property
  19661. * @returns the world matrix
  19662. */
  19663. computeWorldMatrix(): Matrix;
  19664. /**
  19665. * Returns the integer 3.
  19666. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19667. */
  19668. getTypeID(): number;
  19669. /**
  19670. * Prepares the list of defines specific to the light type.
  19671. * @param defines the list of defines
  19672. * @param lightIndex defines the index of the light for the effect
  19673. */
  19674. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19675. }
  19676. }
  19677. declare module BABYLON {
  19678. /** @hidden */
  19679. export var vrMultiviewToSingleviewPixelShader: {
  19680. name: string;
  19681. shader: string;
  19682. };
  19683. }
  19684. declare module BABYLON {
  19685. /**
  19686. * Renders to multiple views with a single draw call
  19687. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19688. */
  19689. export class MultiviewRenderTarget extends RenderTargetTexture {
  19690. /**
  19691. * Creates a multiview render target
  19692. * @param scene scene used with the render target
  19693. * @param size the size of the render target (used for each view)
  19694. */
  19695. constructor(scene: Scene, size?: number | {
  19696. width: number;
  19697. height: number;
  19698. } | {
  19699. ratio: number;
  19700. });
  19701. /**
  19702. * @hidden
  19703. * @param faceIndex the face index, if its a cube texture
  19704. */
  19705. _bindFrameBuffer(faceIndex?: number): void;
  19706. /**
  19707. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19708. * @returns the view count
  19709. */
  19710. getViewCount(): number;
  19711. }
  19712. }
  19713. declare module BABYLON {
  19714. interface Engine {
  19715. /**
  19716. * Creates a new multiview render target
  19717. * @param width defines the width of the texture
  19718. * @param height defines the height of the texture
  19719. * @returns the created multiview texture
  19720. */
  19721. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19722. /**
  19723. * Binds a multiview framebuffer to be drawn to
  19724. * @param multiviewTexture texture to bind
  19725. */
  19726. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19727. }
  19728. interface Camera {
  19729. /**
  19730. * @hidden
  19731. * 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)
  19732. */
  19733. _useMultiviewToSingleView: boolean;
  19734. /**
  19735. * @hidden
  19736. * 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)
  19737. */
  19738. _multiviewTexture: Nullable<RenderTargetTexture>;
  19739. /**
  19740. * @hidden
  19741. * ensures the multiview texture of the camera exists and has the specified width/height
  19742. * @param width height to set on the multiview texture
  19743. * @param height width to set on the multiview texture
  19744. */
  19745. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19746. }
  19747. interface Scene {
  19748. /** @hidden */
  19749. _transformMatrixR: Matrix;
  19750. /** @hidden */
  19751. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19752. /** @hidden */
  19753. _createMultiviewUbo(): void;
  19754. /** @hidden */
  19755. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19756. /** @hidden */
  19757. _renderMultiviewToSingleView(camera: Camera): void;
  19758. }
  19759. }
  19760. declare module BABYLON {
  19761. /**
  19762. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19763. * This will not be used for webXR as it supports displaying texture arrays directly
  19764. */
  19765. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19766. /**
  19767. * Gets a string identifying the name of the class
  19768. * @returns "VRMultiviewToSingleviewPostProcess" string
  19769. */
  19770. getClassName(): string;
  19771. /**
  19772. * Initializes a VRMultiviewToSingleview
  19773. * @param name name of the post process
  19774. * @param camera camera to be applied to
  19775. * @param scaleFactor scaling factor to the size of the output texture
  19776. */
  19777. constructor(name: string, camera: Camera, scaleFactor: number);
  19778. }
  19779. }
  19780. declare module BABYLON {
  19781. /**
  19782. * Interface used to define additional presentation attributes
  19783. */
  19784. export interface IVRPresentationAttributes {
  19785. /**
  19786. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19787. */
  19788. highRefreshRate: boolean;
  19789. /**
  19790. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19791. */
  19792. foveationLevel: number;
  19793. }
  19794. interface Engine {
  19795. /** @hidden */
  19796. _vrDisplay: any;
  19797. /** @hidden */
  19798. _vrSupported: boolean;
  19799. /** @hidden */
  19800. _oldSize: Size;
  19801. /** @hidden */
  19802. _oldHardwareScaleFactor: number;
  19803. /** @hidden */
  19804. _vrExclusivePointerMode: boolean;
  19805. /** @hidden */
  19806. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19807. /** @hidden */
  19808. _onVRDisplayPointerRestricted: () => void;
  19809. /** @hidden */
  19810. _onVRDisplayPointerUnrestricted: () => void;
  19811. /** @hidden */
  19812. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19813. /** @hidden */
  19814. _onVrDisplayDisconnect: Nullable<() => void>;
  19815. /** @hidden */
  19816. _onVrDisplayPresentChange: Nullable<() => void>;
  19817. /**
  19818. * Observable signaled when VR display mode changes
  19819. */
  19820. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19821. /**
  19822. * Observable signaled when VR request present is complete
  19823. */
  19824. onVRRequestPresentComplete: Observable<boolean>;
  19825. /**
  19826. * Observable signaled when VR request present starts
  19827. */
  19828. onVRRequestPresentStart: Observable<Engine>;
  19829. /**
  19830. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19831. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19832. */
  19833. isInVRExclusivePointerMode: boolean;
  19834. /**
  19835. * Gets a boolean indicating if a webVR device was detected
  19836. * @returns true if a webVR device was detected
  19837. */
  19838. isVRDevicePresent(): boolean;
  19839. /**
  19840. * Gets the current webVR device
  19841. * @returns the current webVR device (or null)
  19842. */
  19843. getVRDevice(): any;
  19844. /**
  19845. * Initializes a webVR display and starts listening to display change events
  19846. * The onVRDisplayChangedObservable will be notified upon these changes
  19847. * @returns A promise containing a VRDisplay and if vr is supported
  19848. */
  19849. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19850. /** @hidden */
  19851. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19852. /**
  19853. * Gets or sets the presentation attributes used to configure VR rendering
  19854. */
  19855. vrPresentationAttributes?: IVRPresentationAttributes;
  19856. /**
  19857. * Call this function to switch to webVR mode
  19858. * Will do nothing if webVR is not supported or if there is no webVR device
  19859. * @param options the webvr options provided to the camera. mainly used for multiview
  19860. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19861. */
  19862. enableVR(options: WebVROptions): void;
  19863. /** @hidden */
  19864. _onVRFullScreenTriggered(): void;
  19865. }
  19866. }
  19867. declare module BABYLON {
  19868. /**
  19869. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19870. * IMPORTANT!! The data is right-hand data.
  19871. * @export
  19872. * @interface DevicePose
  19873. */
  19874. export interface DevicePose {
  19875. /**
  19876. * The position of the device, values in array are [x,y,z].
  19877. */
  19878. readonly position: Nullable<Float32Array>;
  19879. /**
  19880. * The linearVelocity of the device, values in array are [x,y,z].
  19881. */
  19882. readonly linearVelocity: Nullable<Float32Array>;
  19883. /**
  19884. * The linearAcceleration of the device, values in array are [x,y,z].
  19885. */
  19886. readonly linearAcceleration: Nullable<Float32Array>;
  19887. /**
  19888. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19889. */
  19890. readonly orientation: Nullable<Float32Array>;
  19891. /**
  19892. * The angularVelocity of the device, values in array are [x,y,z].
  19893. */
  19894. readonly angularVelocity: Nullable<Float32Array>;
  19895. /**
  19896. * The angularAcceleration of the device, values in array are [x,y,z].
  19897. */
  19898. readonly angularAcceleration: Nullable<Float32Array>;
  19899. }
  19900. /**
  19901. * Interface representing a pose controlled object in Babylon.
  19902. * A pose controlled object has both regular pose values as well as pose values
  19903. * from an external device such as a VR head mounted display
  19904. */
  19905. export interface PoseControlled {
  19906. /**
  19907. * The position of the object in babylon space.
  19908. */
  19909. position: Vector3;
  19910. /**
  19911. * The rotation quaternion of the object in babylon space.
  19912. */
  19913. rotationQuaternion: Quaternion;
  19914. /**
  19915. * The position of the device in babylon space.
  19916. */
  19917. devicePosition?: Vector3;
  19918. /**
  19919. * The rotation quaternion of the device in babylon space.
  19920. */
  19921. deviceRotationQuaternion: Quaternion;
  19922. /**
  19923. * The raw pose coming from the device.
  19924. */
  19925. rawPose: Nullable<DevicePose>;
  19926. /**
  19927. * The scale of the device to be used when translating from device space to babylon space.
  19928. */
  19929. deviceScaleFactor: number;
  19930. /**
  19931. * Updates the poseControlled values based on the input device pose.
  19932. * @param poseData the pose data to update the object with
  19933. */
  19934. updateFromDevice(poseData: DevicePose): void;
  19935. }
  19936. /**
  19937. * Set of options to customize the webVRCamera
  19938. */
  19939. export interface WebVROptions {
  19940. /**
  19941. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19942. */
  19943. trackPosition?: boolean;
  19944. /**
  19945. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19946. */
  19947. positionScale?: number;
  19948. /**
  19949. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19950. */
  19951. displayName?: string;
  19952. /**
  19953. * Should the native controller meshes be initialized. (default: true)
  19954. */
  19955. controllerMeshes?: boolean;
  19956. /**
  19957. * Creating a default HemiLight only on controllers. (default: true)
  19958. */
  19959. defaultLightingOnControllers?: boolean;
  19960. /**
  19961. * If you don't want to use the default VR button of the helper. (default: false)
  19962. */
  19963. useCustomVRButton?: boolean;
  19964. /**
  19965. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19966. */
  19967. customVRButton?: HTMLButtonElement;
  19968. /**
  19969. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19970. */
  19971. rayLength?: number;
  19972. /**
  19973. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19974. */
  19975. defaultHeight?: number;
  19976. /**
  19977. * If multiview should be used if availible (default: false)
  19978. */
  19979. useMultiview?: boolean;
  19980. }
  19981. /**
  19982. * This represents a WebVR camera.
  19983. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19984. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19985. */
  19986. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19987. private webVROptions;
  19988. /**
  19989. * @hidden
  19990. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19991. */
  19992. _vrDevice: any;
  19993. /**
  19994. * The rawPose of the vrDevice.
  19995. */
  19996. rawPose: Nullable<DevicePose>;
  19997. private _onVREnabled;
  19998. private _specsVersion;
  19999. private _attached;
  20000. private _frameData;
  20001. protected _descendants: Array<Node>;
  20002. private _deviceRoomPosition;
  20003. /** @hidden */
  20004. _deviceRoomRotationQuaternion: Quaternion;
  20005. private _standingMatrix;
  20006. /**
  20007. * Represents device position in babylon space.
  20008. */
  20009. devicePosition: Vector3;
  20010. /**
  20011. * Represents device rotation in babylon space.
  20012. */
  20013. deviceRotationQuaternion: Quaternion;
  20014. /**
  20015. * The scale of the device to be used when translating from device space to babylon space.
  20016. */
  20017. deviceScaleFactor: number;
  20018. private _deviceToWorld;
  20019. private _worldToDevice;
  20020. /**
  20021. * References to the webVR controllers for the vrDevice.
  20022. */
  20023. controllers: Array<WebVRController>;
  20024. /**
  20025. * Emits an event when a controller is attached.
  20026. */
  20027. onControllersAttachedObservable: Observable<WebVRController[]>;
  20028. /**
  20029. * Emits an event when a controller's mesh has been loaded;
  20030. */
  20031. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20032. /**
  20033. * Emits an event when the HMD's pose has been updated.
  20034. */
  20035. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20036. private _poseSet;
  20037. /**
  20038. * If the rig cameras be used as parent instead of this camera.
  20039. */
  20040. rigParenting: boolean;
  20041. private _lightOnControllers;
  20042. private _defaultHeight?;
  20043. /**
  20044. * Instantiates a WebVRFreeCamera.
  20045. * @param name The name of the WebVRFreeCamera
  20046. * @param position The starting anchor position for the camera
  20047. * @param scene The scene the camera belongs to
  20048. * @param webVROptions a set of customizable options for the webVRCamera
  20049. */
  20050. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20051. /**
  20052. * Gets the device distance from the ground in meters.
  20053. * @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.
  20054. */
  20055. deviceDistanceToRoomGround(): number;
  20056. /**
  20057. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20058. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20059. */
  20060. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20061. /**
  20062. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20063. * @returns A promise with a boolean set to if the standing matrix is supported.
  20064. */
  20065. useStandingMatrixAsync(): Promise<boolean>;
  20066. /**
  20067. * Disposes the camera
  20068. */
  20069. dispose(): void;
  20070. /**
  20071. * Gets a vrController by name.
  20072. * @param name The name of the controller to retreive
  20073. * @returns the controller matching the name specified or null if not found
  20074. */
  20075. getControllerByName(name: string): Nullable<WebVRController>;
  20076. private _leftController;
  20077. /**
  20078. * The controller corresponding to the users left hand.
  20079. */
  20080. get leftController(): Nullable<WebVRController>;
  20081. private _rightController;
  20082. /**
  20083. * The controller corresponding to the users right hand.
  20084. */
  20085. get rightController(): Nullable<WebVRController>;
  20086. /**
  20087. * Casts a ray forward from the vrCamera's gaze.
  20088. * @param length Length of the ray (default: 100)
  20089. * @returns the ray corresponding to the gaze
  20090. */
  20091. getForwardRay(length?: number): Ray;
  20092. /**
  20093. * @hidden
  20094. * Updates the camera based on device's frame data
  20095. */
  20096. _checkInputs(): void;
  20097. /**
  20098. * Updates the poseControlled values based on the input device pose.
  20099. * @param poseData Pose coming from the device
  20100. */
  20101. updateFromDevice(poseData: DevicePose): void;
  20102. private _htmlElementAttached;
  20103. private _detachIfAttached;
  20104. /**
  20105. * WebVR's attach control will start broadcasting frames to the device.
  20106. * Note that in certain browsers (chrome for example) this function must be called
  20107. * within a user-interaction callback. Example:
  20108. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20109. *
  20110. * @param element html element to attach the vrDevice to
  20111. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20112. */
  20113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20114. /**
  20115. * Detaches the camera from the html element and disables VR
  20116. *
  20117. * @param element html element to detach from
  20118. */
  20119. detachControl(element: HTMLElement): void;
  20120. /**
  20121. * @returns the name of this class
  20122. */
  20123. getClassName(): string;
  20124. /**
  20125. * Calls resetPose on the vrDisplay
  20126. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20127. */
  20128. resetToCurrentRotation(): void;
  20129. /**
  20130. * @hidden
  20131. * Updates the rig cameras (left and right eye)
  20132. */
  20133. _updateRigCameras(): void;
  20134. private _workingVector;
  20135. private _oneVector;
  20136. private _workingMatrix;
  20137. private updateCacheCalled;
  20138. private _correctPositionIfNotTrackPosition;
  20139. /**
  20140. * @hidden
  20141. * Updates the cached values of the camera
  20142. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20143. */
  20144. _updateCache(ignoreParentClass?: boolean): void;
  20145. /**
  20146. * @hidden
  20147. * Get current device position in babylon world
  20148. */
  20149. _computeDevicePosition(): void;
  20150. /**
  20151. * Updates the current device position and rotation in the babylon world
  20152. */
  20153. update(): void;
  20154. /**
  20155. * @hidden
  20156. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20157. * @returns an identity matrix
  20158. */
  20159. _getViewMatrix(): Matrix;
  20160. private _tmpMatrix;
  20161. /**
  20162. * This function is called by the two RIG cameras.
  20163. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20164. * @hidden
  20165. */
  20166. _getWebVRViewMatrix(): Matrix;
  20167. /** @hidden */
  20168. _getWebVRProjectionMatrix(): Matrix;
  20169. private _onGamepadConnectedObserver;
  20170. private _onGamepadDisconnectedObserver;
  20171. private _updateCacheWhenTrackingDisabledObserver;
  20172. /**
  20173. * Initializes the controllers and their meshes
  20174. */
  20175. initControllers(): void;
  20176. }
  20177. }
  20178. declare module BABYLON {
  20179. /**
  20180. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20181. *
  20182. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20183. *
  20184. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20185. */
  20186. export class MaterialHelper {
  20187. /**
  20188. * Bind the current view position to an effect.
  20189. * @param effect The effect to be bound
  20190. * @param scene The scene the eyes position is used from
  20191. * @param variableName name of the shader variable that will hold the eye position
  20192. */
  20193. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20194. /**
  20195. * Helps preparing the defines values about the UVs in used in the effect.
  20196. * UVs are shared as much as we can accross channels in the shaders.
  20197. * @param texture The texture we are preparing the UVs for
  20198. * @param defines The defines to update
  20199. * @param key The channel key "diffuse", "specular"... used in the shader
  20200. */
  20201. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20202. /**
  20203. * Binds a texture matrix value to its corrsponding uniform
  20204. * @param texture The texture to bind the matrix for
  20205. * @param uniformBuffer The uniform buffer receivin the data
  20206. * @param key The channel key "diffuse", "specular"... used in the shader
  20207. */
  20208. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20209. /**
  20210. * Gets the current status of the fog (should it be enabled?)
  20211. * @param mesh defines the mesh to evaluate for fog support
  20212. * @param scene defines the hosting scene
  20213. * @returns true if fog must be enabled
  20214. */
  20215. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20216. /**
  20217. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20218. * @param mesh defines the current mesh
  20219. * @param scene defines the current scene
  20220. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20221. * @param pointsCloud defines if point cloud rendering has to be turned on
  20222. * @param fogEnabled defines if fog has to be turned on
  20223. * @param alphaTest defines if alpha testing has to be turned on
  20224. * @param defines defines the current list of defines
  20225. */
  20226. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20227. /**
  20228. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20229. * @param scene defines the current scene
  20230. * @param engine defines the current engine
  20231. * @param defines specifies the list of active defines
  20232. * @param useInstances defines if instances have to be turned on
  20233. * @param useClipPlane defines if clip plane have to be turned on
  20234. * @param useInstances defines if instances have to be turned on
  20235. * @param useThinInstances defines if thin instances have to be turned on
  20236. */
  20237. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20238. /**
  20239. * Prepares the defines for bones
  20240. * @param mesh The mesh containing the geometry data we will draw
  20241. * @param defines The defines to update
  20242. */
  20243. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20244. /**
  20245. * Prepares the defines for morph targets
  20246. * @param mesh The mesh containing the geometry data we will draw
  20247. * @param defines The defines to update
  20248. */
  20249. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20250. /**
  20251. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20252. * @param mesh The mesh containing the geometry data we will draw
  20253. * @param defines The defines to update
  20254. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20255. * @param useBones Precise whether bones should be used or not (override mesh info)
  20256. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20257. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20258. * @returns false if defines are considered not dirty and have not been checked
  20259. */
  20260. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20261. /**
  20262. * Prepares the defines related to multiview
  20263. * @param scene The scene we are intending to draw
  20264. * @param defines The defines to update
  20265. */
  20266. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20267. /**
  20268. * Prepares the defines related to the prepass
  20269. * @param scene The scene we are intending to draw
  20270. * @param defines The defines to update
  20271. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20272. */
  20273. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20274. /**
  20275. * Prepares the defines related to the light information passed in parameter
  20276. * @param scene The scene we are intending to draw
  20277. * @param mesh The mesh the effect is compiling for
  20278. * @param light The light the effect is compiling for
  20279. * @param lightIndex The index of the light
  20280. * @param defines The defines to update
  20281. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20282. * @param state Defines the current state regarding what is needed (normals, etc...)
  20283. */
  20284. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20285. needNormals: boolean;
  20286. needRebuild: boolean;
  20287. shadowEnabled: boolean;
  20288. specularEnabled: boolean;
  20289. lightmapMode: boolean;
  20290. }): void;
  20291. /**
  20292. * Prepares the defines related to the light information passed in parameter
  20293. * @param scene The scene we are intending to draw
  20294. * @param mesh The mesh the effect is compiling for
  20295. * @param defines The defines to update
  20296. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20297. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20298. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20299. * @returns true if normals will be required for the rest of the effect
  20300. */
  20301. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20302. /**
  20303. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20304. * @param lightIndex defines the light index
  20305. * @param uniformsList The uniform list
  20306. * @param samplersList The sampler list
  20307. * @param projectedLightTexture defines if projected texture must be used
  20308. * @param uniformBuffersList defines an optional list of uniform buffers
  20309. */
  20310. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20311. /**
  20312. * Prepares the uniforms and samplers list to be used in the effect
  20313. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20314. * @param samplersList The sampler list
  20315. * @param defines The defines helping in the list generation
  20316. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20317. */
  20318. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20319. /**
  20320. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20321. * @param defines The defines to update while falling back
  20322. * @param fallbacks The authorized effect fallbacks
  20323. * @param maxSimultaneousLights The maximum number of lights allowed
  20324. * @param rank the current rank of the Effect
  20325. * @returns The newly affected rank
  20326. */
  20327. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20328. private static _TmpMorphInfluencers;
  20329. /**
  20330. * Prepares the list of attributes required for morph targets according to the effect defines.
  20331. * @param attribs The current list of supported attribs
  20332. * @param mesh The mesh to prepare the morph targets attributes for
  20333. * @param influencers The number of influencers
  20334. */
  20335. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20336. /**
  20337. * Prepares the list of attributes required for morph targets according to the effect defines.
  20338. * @param attribs The current list of supported attribs
  20339. * @param mesh The mesh to prepare the morph targets attributes for
  20340. * @param defines The current Defines of the effect
  20341. */
  20342. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20343. /**
  20344. * Prepares the list of attributes required for bones according to the effect defines.
  20345. * @param attribs The current list of supported attribs
  20346. * @param mesh The mesh to prepare the bones attributes for
  20347. * @param defines The current Defines of the effect
  20348. * @param fallbacks The current efffect fallback strategy
  20349. */
  20350. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20351. /**
  20352. * Check and prepare the list of attributes required for instances according to the effect defines.
  20353. * @param attribs The current list of supported attribs
  20354. * @param defines The current MaterialDefines of the effect
  20355. */
  20356. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20357. /**
  20358. * Add the list of attributes required for instances to the attribs array.
  20359. * @param attribs The current list of supported attribs
  20360. */
  20361. static PushAttributesForInstances(attribs: string[]): void;
  20362. /**
  20363. * Binds the light information to the effect.
  20364. * @param light The light containing the generator
  20365. * @param effect The effect we are binding the data to
  20366. * @param lightIndex The light index in the effect used to render
  20367. */
  20368. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20369. /**
  20370. * Binds the lights information from the scene to the effect for the given mesh.
  20371. * @param light Light to bind
  20372. * @param lightIndex Light index
  20373. * @param scene The scene where the light belongs to
  20374. * @param effect The effect we are binding the data to
  20375. * @param useSpecular Defines if specular is supported
  20376. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20377. */
  20378. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20379. /**
  20380. * Binds the lights information from the scene to the effect for the given mesh.
  20381. * @param scene The scene the lights belongs to
  20382. * @param mesh The mesh we are binding the information to render
  20383. * @param effect The effect we are binding the data to
  20384. * @param defines The generated defines for the effect
  20385. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20386. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20387. */
  20388. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20389. private static _tempFogColor;
  20390. /**
  20391. * Binds the fog information from the scene to the effect for the given mesh.
  20392. * @param scene The scene the lights belongs to
  20393. * @param mesh The mesh we are binding the information to render
  20394. * @param effect The effect we are binding the data to
  20395. * @param linearSpace Defines if the fog effect is applied in linear space
  20396. */
  20397. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20398. /**
  20399. * Binds the bones information from the mesh to the effect.
  20400. * @param mesh The mesh we are binding the information to render
  20401. * @param effect The effect we are binding the data to
  20402. */
  20403. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20404. /**
  20405. * Binds the morph targets information from the mesh to the effect.
  20406. * @param abstractMesh The mesh we are binding the information to render
  20407. * @param effect The effect we are binding the data to
  20408. */
  20409. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20410. /**
  20411. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20412. * @param defines The generated defines used in the effect
  20413. * @param effect The effect we are binding the data to
  20414. * @param scene The scene we are willing to render with logarithmic scale for
  20415. */
  20416. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20417. /**
  20418. * Binds the clip plane information from the scene to the effect.
  20419. * @param scene The scene the clip plane information are extracted from
  20420. * @param effect The effect we are binding the data to
  20421. */
  20422. static BindClipPlane(effect: Effect, scene: Scene): void;
  20423. }
  20424. }
  20425. declare module BABYLON {
  20426. /**
  20427. * Block used to expose an input value
  20428. */
  20429. export class InputBlock extends NodeMaterialBlock {
  20430. private _mode;
  20431. private _associatedVariableName;
  20432. private _storedValue;
  20433. private _valueCallback;
  20434. private _type;
  20435. private _animationType;
  20436. /** Gets or set a value used to limit the range of float values */
  20437. min: number;
  20438. /** Gets or set a value used to limit the range of float values */
  20439. max: number;
  20440. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20441. isBoolean: boolean;
  20442. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20443. matrixMode: number;
  20444. /** @hidden */
  20445. _systemValue: Nullable<NodeMaterialSystemValues>;
  20446. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20447. visibleInInspector: boolean;
  20448. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20449. isConstant: boolean;
  20450. /** Gets or sets the group to use to display this block in the Inspector */
  20451. groupInInspector: string;
  20452. /** Gets an observable raised when the value is changed */
  20453. onValueChangedObservable: Observable<InputBlock>;
  20454. /**
  20455. * Gets or sets the connection point type (default is float)
  20456. */
  20457. get type(): NodeMaterialBlockConnectionPointTypes;
  20458. /**
  20459. * Creates a new InputBlock
  20460. * @param name defines the block name
  20461. * @param target defines the target of that block (Vertex by default)
  20462. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20463. */
  20464. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20465. /**
  20466. * Validates if a name is a reserve word.
  20467. * @param newName the new name to be given to the node.
  20468. * @returns false if the name is a reserve word, else true.
  20469. */
  20470. validateBlockName(newName: string): boolean;
  20471. /**
  20472. * Gets the output component
  20473. */
  20474. get output(): NodeMaterialConnectionPoint;
  20475. /**
  20476. * Set the source of this connection point to a vertex attribute
  20477. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20478. * @returns the current connection point
  20479. */
  20480. setAsAttribute(attributeName?: string): InputBlock;
  20481. /**
  20482. * Set the source of this connection point to a system value
  20483. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20484. * @returns the current connection point
  20485. */
  20486. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20487. /**
  20488. * Gets or sets the value of that point.
  20489. * Please note that this value will be ignored if valueCallback is defined
  20490. */
  20491. get value(): any;
  20492. set value(value: any);
  20493. /**
  20494. * Gets or sets a callback used to get the value of that point.
  20495. * Please note that setting this value will force the connection point to ignore the value property
  20496. */
  20497. get valueCallback(): () => any;
  20498. set valueCallback(value: () => any);
  20499. /**
  20500. * Gets or sets the associated variable name in the shader
  20501. */
  20502. get associatedVariableName(): string;
  20503. set associatedVariableName(value: string);
  20504. /** Gets or sets the type of animation applied to the input */
  20505. get animationType(): AnimatedInputBlockTypes;
  20506. set animationType(value: AnimatedInputBlockTypes);
  20507. /**
  20508. * Gets a boolean indicating that this connection point not defined yet
  20509. */
  20510. get isUndefined(): boolean;
  20511. /**
  20512. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20513. * In this case the connection point name must be the name of the uniform to use.
  20514. * Can only be set on inputs
  20515. */
  20516. get isUniform(): boolean;
  20517. set isUniform(value: boolean);
  20518. /**
  20519. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20520. * In this case the connection point name must be the name of the attribute to use
  20521. * Can only be set on inputs
  20522. */
  20523. get isAttribute(): boolean;
  20524. set isAttribute(value: boolean);
  20525. /**
  20526. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20527. * Can only be set on exit points
  20528. */
  20529. get isVarying(): boolean;
  20530. set isVarying(value: boolean);
  20531. /**
  20532. * Gets a boolean indicating that the current connection point is a system value
  20533. */
  20534. get isSystemValue(): boolean;
  20535. /**
  20536. * Gets or sets the current well known value or null if not defined as a system value
  20537. */
  20538. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20539. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20540. /**
  20541. * Gets the current class name
  20542. * @returns the class name
  20543. */
  20544. getClassName(): string;
  20545. /**
  20546. * Animate the input if animationType !== None
  20547. * @param scene defines the rendering scene
  20548. */
  20549. animate(scene: Scene): void;
  20550. private _emitDefine;
  20551. initialize(state: NodeMaterialBuildState): void;
  20552. /**
  20553. * Set the input block to its default value (based on its type)
  20554. */
  20555. setDefaultValue(): void;
  20556. private _emitConstant;
  20557. /** @hidden */
  20558. get _noContextSwitch(): boolean;
  20559. private _emit;
  20560. /** @hidden */
  20561. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20562. /** @hidden */
  20563. _transmit(effect: Effect, scene: Scene): void;
  20564. protected _buildBlock(state: NodeMaterialBuildState): void;
  20565. protected _dumpPropertiesCode(): string;
  20566. dispose(): void;
  20567. serialize(): any;
  20568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20569. }
  20570. }
  20571. declare module BABYLON {
  20572. /**
  20573. * Enum used to define the compatibility state between two connection points
  20574. */
  20575. export enum NodeMaterialConnectionPointCompatibilityStates {
  20576. /** Points are compatibles */
  20577. Compatible = 0,
  20578. /** Points are incompatible because of their types */
  20579. TypeIncompatible = 1,
  20580. /** Points are incompatible because of their targets (vertex vs fragment) */
  20581. TargetIncompatible = 2
  20582. }
  20583. /**
  20584. * Defines the direction of a connection point
  20585. */
  20586. export enum NodeMaterialConnectionPointDirection {
  20587. /** Input */
  20588. Input = 0,
  20589. /** Output */
  20590. Output = 1
  20591. }
  20592. /**
  20593. * Defines a connection point for a block
  20594. */
  20595. export class NodeMaterialConnectionPoint {
  20596. /** @hidden */
  20597. _ownerBlock: NodeMaterialBlock;
  20598. /** @hidden */
  20599. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20600. private _endpoints;
  20601. private _associatedVariableName;
  20602. private _direction;
  20603. /** @hidden */
  20604. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20605. /** @hidden */
  20606. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20607. private _type;
  20608. /** @hidden */
  20609. _enforceAssociatedVariableName: boolean;
  20610. /** Gets the direction of the point */
  20611. get direction(): NodeMaterialConnectionPointDirection;
  20612. /** Indicates that this connection point needs dual validation before being connected to another point */
  20613. needDualDirectionValidation: boolean;
  20614. /**
  20615. * Gets or sets the additional types supported by this connection point
  20616. */
  20617. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20618. /**
  20619. * Gets or sets the additional types excluded by this connection point
  20620. */
  20621. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20622. /**
  20623. * Observable triggered when this point is connected
  20624. */
  20625. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20626. /**
  20627. * Gets or sets the associated variable name in the shader
  20628. */
  20629. get associatedVariableName(): string;
  20630. set associatedVariableName(value: string);
  20631. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20632. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20633. /**
  20634. * Gets or sets the connection point type (default is float)
  20635. */
  20636. get type(): NodeMaterialBlockConnectionPointTypes;
  20637. set type(value: NodeMaterialBlockConnectionPointTypes);
  20638. /**
  20639. * Gets or sets the connection point name
  20640. */
  20641. name: string;
  20642. /**
  20643. * Gets or sets the connection point name
  20644. */
  20645. displayName: string;
  20646. /**
  20647. * Gets or sets a boolean indicating that this connection point can be omitted
  20648. */
  20649. isOptional: boolean;
  20650. /**
  20651. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20652. */
  20653. isExposedOnFrame: boolean;
  20654. /**
  20655. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20656. */
  20657. define: string;
  20658. /** @hidden */
  20659. _prioritizeVertex: boolean;
  20660. private _target;
  20661. /** Gets or sets the target of that connection point */
  20662. get target(): NodeMaterialBlockTargets;
  20663. set target(value: NodeMaterialBlockTargets);
  20664. /**
  20665. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20666. */
  20667. get isConnected(): boolean;
  20668. /**
  20669. * Gets a boolean indicating that the current point is connected to an input block
  20670. */
  20671. get isConnectedToInputBlock(): boolean;
  20672. /**
  20673. * Gets a the connected input block (if any)
  20674. */
  20675. get connectInputBlock(): Nullable<InputBlock>;
  20676. /** Get the other side of the connection (if any) */
  20677. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20678. /** Get the block that owns this connection point */
  20679. get ownerBlock(): NodeMaterialBlock;
  20680. /** Get the block connected on the other side of this connection (if any) */
  20681. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20682. /** Get the block connected on the endpoints of this connection (if any) */
  20683. get connectedBlocks(): Array<NodeMaterialBlock>;
  20684. /** Gets the list of connected endpoints */
  20685. get endpoints(): NodeMaterialConnectionPoint[];
  20686. /** Gets a boolean indicating if that output point is connected to at least one input */
  20687. get hasEndpoints(): boolean;
  20688. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20689. get isConnectedInVertexShader(): boolean;
  20690. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20691. get isConnectedInFragmentShader(): boolean;
  20692. /**
  20693. * Creates a block suitable to be used as an input for this input point.
  20694. * If null is returned, a block based on the point type will be created.
  20695. * @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
  20696. */
  20697. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20698. /**
  20699. * Creates a new connection point
  20700. * @param name defines the connection point name
  20701. * @param ownerBlock defines the block hosting this connection point
  20702. * @param direction defines the direction of the connection point
  20703. */
  20704. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20705. /**
  20706. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20707. * @returns the class name
  20708. */
  20709. getClassName(): string;
  20710. /**
  20711. * Gets a boolean indicating if the current point can be connected to another point
  20712. * @param connectionPoint defines the other connection point
  20713. * @returns a boolean
  20714. */
  20715. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20716. /**
  20717. * Gets a number indicating if the current point can be connected to another point
  20718. * @param connectionPoint defines the other connection point
  20719. * @returns a number defining the compatibility state
  20720. */
  20721. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20722. /**
  20723. * Connect this point to another connection point
  20724. * @param connectionPoint defines the other connection point
  20725. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20726. * @returns the current connection point
  20727. */
  20728. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20729. /**
  20730. * Disconnect this point from one of his endpoint
  20731. * @param endpoint defines the other connection point
  20732. * @returns the current connection point
  20733. */
  20734. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20735. /**
  20736. * Serializes this point in a JSON representation
  20737. * @param isInput defines if the connection point is an input (default is true)
  20738. * @returns the serialized point object
  20739. */
  20740. serialize(isInput?: boolean): any;
  20741. /**
  20742. * Release resources
  20743. */
  20744. dispose(): void;
  20745. }
  20746. }
  20747. declare module BABYLON {
  20748. /**
  20749. * Enum used to define the material modes
  20750. */
  20751. export enum NodeMaterialModes {
  20752. /** Regular material */
  20753. Material = 0,
  20754. /** For post process */
  20755. PostProcess = 1,
  20756. /** For particle system */
  20757. Particle = 2
  20758. }
  20759. }
  20760. declare module BABYLON {
  20761. /**
  20762. * Block used to read a texture from a sampler
  20763. */
  20764. export class TextureBlock extends NodeMaterialBlock {
  20765. private _defineName;
  20766. private _linearDefineName;
  20767. private _gammaDefineName;
  20768. private _tempTextureRead;
  20769. private _samplerName;
  20770. private _transformedUVName;
  20771. private _textureTransformName;
  20772. private _textureInfoName;
  20773. private _mainUVName;
  20774. private _mainUVDefineName;
  20775. private _fragmentOnly;
  20776. /**
  20777. * Gets or sets the texture associated with the node
  20778. */
  20779. texture: Nullable<Texture>;
  20780. /**
  20781. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20782. */
  20783. convertToGammaSpace: boolean;
  20784. /**
  20785. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20786. */
  20787. convertToLinearSpace: boolean;
  20788. /**
  20789. * Create a new TextureBlock
  20790. * @param name defines the block name
  20791. */
  20792. constructor(name: string, fragmentOnly?: boolean);
  20793. /**
  20794. * Gets the current class name
  20795. * @returns the class name
  20796. */
  20797. getClassName(): string;
  20798. /**
  20799. * Gets the uv input component
  20800. */
  20801. get uv(): NodeMaterialConnectionPoint;
  20802. /**
  20803. * Gets the rgba output component
  20804. */
  20805. get rgba(): NodeMaterialConnectionPoint;
  20806. /**
  20807. * Gets the rgb output component
  20808. */
  20809. get rgb(): NodeMaterialConnectionPoint;
  20810. /**
  20811. * Gets the r output component
  20812. */
  20813. get r(): NodeMaterialConnectionPoint;
  20814. /**
  20815. * Gets the g output component
  20816. */
  20817. get g(): NodeMaterialConnectionPoint;
  20818. /**
  20819. * Gets the b output component
  20820. */
  20821. get b(): NodeMaterialConnectionPoint;
  20822. /**
  20823. * Gets the a output component
  20824. */
  20825. get a(): NodeMaterialConnectionPoint;
  20826. get target(): NodeMaterialBlockTargets;
  20827. autoConfigure(material: NodeMaterial): void;
  20828. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20829. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20830. isReady(): boolean;
  20831. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20832. private get _isMixed();
  20833. private _injectVertexCode;
  20834. private _writeTextureRead;
  20835. private _writeOutput;
  20836. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20837. protected _dumpPropertiesCode(): string;
  20838. serialize(): any;
  20839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20840. }
  20841. }
  20842. declare module BABYLON {
  20843. /** @hidden */
  20844. export var reflectionFunction: {
  20845. name: string;
  20846. shader: string;
  20847. };
  20848. }
  20849. declare module BABYLON {
  20850. /**
  20851. * Base block used to read a reflection texture from a sampler
  20852. */
  20853. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20854. /** @hidden */
  20855. _define3DName: string;
  20856. /** @hidden */
  20857. _defineCubicName: string;
  20858. /** @hidden */
  20859. _defineExplicitName: string;
  20860. /** @hidden */
  20861. _defineProjectionName: string;
  20862. /** @hidden */
  20863. _defineLocalCubicName: string;
  20864. /** @hidden */
  20865. _defineSphericalName: string;
  20866. /** @hidden */
  20867. _definePlanarName: string;
  20868. /** @hidden */
  20869. _defineEquirectangularName: string;
  20870. /** @hidden */
  20871. _defineMirroredEquirectangularFixedName: string;
  20872. /** @hidden */
  20873. _defineEquirectangularFixedName: string;
  20874. /** @hidden */
  20875. _defineSkyboxName: string;
  20876. /** @hidden */
  20877. _defineOppositeZ: string;
  20878. /** @hidden */
  20879. _cubeSamplerName: string;
  20880. /** @hidden */
  20881. _2DSamplerName: string;
  20882. protected _positionUVWName: string;
  20883. protected _directionWName: string;
  20884. protected _reflectionVectorName: string;
  20885. /** @hidden */
  20886. _reflectionCoordsName: string;
  20887. /** @hidden */
  20888. _reflectionMatrixName: string;
  20889. protected _reflectionColorName: string;
  20890. /**
  20891. * Gets or sets the texture associated with the node
  20892. */
  20893. texture: Nullable<BaseTexture>;
  20894. /**
  20895. * Create a new ReflectionTextureBaseBlock
  20896. * @param name defines the block name
  20897. */
  20898. constructor(name: string);
  20899. /**
  20900. * Gets the current class name
  20901. * @returns the class name
  20902. */
  20903. getClassName(): string;
  20904. /**
  20905. * Gets the world position input component
  20906. */
  20907. abstract get position(): NodeMaterialConnectionPoint;
  20908. /**
  20909. * Gets the world position input component
  20910. */
  20911. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20912. /**
  20913. * Gets the world normal input component
  20914. */
  20915. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20916. /**
  20917. * Gets the world input component
  20918. */
  20919. abstract get world(): NodeMaterialConnectionPoint;
  20920. /**
  20921. * Gets the camera (or eye) position component
  20922. */
  20923. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20924. /**
  20925. * Gets the view input component
  20926. */
  20927. abstract get view(): NodeMaterialConnectionPoint;
  20928. protected _getTexture(): Nullable<BaseTexture>;
  20929. autoConfigure(material: NodeMaterial): void;
  20930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20931. isReady(): boolean;
  20932. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20933. /**
  20934. * Gets the code to inject in the vertex shader
  20935. * @param state current state of the node material building
  20936. * @returns the shader code
  20937. */
  20938. handleVertexSide(state: NodeMaterialBuildState): string;
  20939. /**
  20940. * Handles the inits for the fragment code path
  20941. * @param state node material build state
  20942. */
  20943. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20944. /**
  20945. * Generates the reflection coords code for the fragment code path
  20946. * @param worldNormalVarName name of the world normal variable
  20947. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20948. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20949. * @returns the shader code
  20950. */
  20951. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20952. /**
  20953. * Generates the reflection color code for the fragment code path
  20954. * @param lodVarName name of the lod variable
  20955. * @param swizzleLookupTexture swizzle to use for the final color variable
  20956. * @returns the shader code
  20957. */
  20958. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20959. /**
  20960. * Generates the code corresponding to the connected output points
  20961. * @param state node material build state
  20962. * @param varName name of the variable to output
  20963. * @returns the shader code
  20964. */
  20965. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20966. protected _buildBlock(state: NodeMaterialBuildState): this;
  20967. protected _dumpPropertiesCode(): string;
  20968. serialize(): any;
  20969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20970. }
  20971. }
  20972. declare module BABYLON {
  20973. /**
  20974. * Defines a connection point to be used for points with a custom object type
  20975. */
  20976. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20977. private _blockType;
  20978. private _blockName;
  20979. private _nameForCheking?;
  20980. /**
  20981. * Creates a new connection point
  20982. * @param name defines the connection point name
  20983. * @param ownerBlock defines the block hosting this connection point
  20984. * @param direction defines the direction of the connection point
  20985. */
  20986. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20987. /**
  20988. * Gets a number indicating if the current point can be connected to another point
  20989. * @param connectionPoint defines the other connection point
  20990. * @returns a number defining the compatibility state
  20991. */
  20992. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20993. /**
  20994. * Creates a block suitable to be used as an input for this input point.
  20995. * If null is returned, a block based on the point type will be created.
  20996. * @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
  20997. */
  20998. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20999. }
  21000. }
  21001. declare module BABYLON {
  21002. /**
  21003. * Enum defining the type of properties that can be edited in the property pages in the NME
  21004. */
  21005. export enum PropertyTypeForEdition {
  21006. /** property is a boolean */
  21007. Boolean = 0,
  21008. /** property is a float */
  21009. Float = 1,
  21010. /** property is a Vector2 */
  21011. Vector2 = 2,
  21012. /** property is a list of values */
  21013. List = 3
  21014. }
  21015. /**
  21016. * Interface that defines an option in a variable of type list
  21017. */
  21018. export interface IEditablePropertyListOption {
  21019. /** label of the option */
  21020. "label": string;
  21021. /** value of the option */
  21022. "value": number;
  21023. }
  21024. /**
  21025. * Interface that defines the options available for an editable property
  21026. */
  21027. export interface IEditablePropertyOption {
  21028. /** min value */
  21029. "min"?: number;
  21030. /** max value */
  21031. "max"?: number;
  21032. /** notifiers: indicates which actions to take when the property is changed */
  21033. "notifiers"?: {
  21034. /** the material should be rebuilt */
  21035. "rebuild"?: boolean;
  21036. /** the preview should be updated */
  21037. "update"?: boolean;
  21038. };
  21039. /** list of the options for a variable of type list */
  21040. "options"?: IEditablePropertyListOption[];
  21041. }
  21042. /**
  21043. * Interface that describes an editable property
  21044. */
  21045. export interface IPropertyDescriptionForEdition {
  21046. /** name of the property */
  21047. "propertyName": string;
  21048. /** display name of the property */
  21049. "displayName": string;
  21050. /** type of the property */
  21051. "type": PropertyTypeForEdition;
  21052. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21053. "groupName": string;
  21054. /** options for the property */
  21055. "options": IEditablePropertyOption;
  21056. }
  21057. /**
  21058. * Decorator that flags a property in a node material block as being editable
  21059. */
  21060. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21061. }
  21062. declare module BABYLON {
  21063. /**
  21064. * Block used to implement the refraction part of the sub surface module of the PBR material
  21065. */
  21066. export class RefractionBlock extends NodeMaterialBlock {
  21067. /** @hidden */
  21068. _define3DName: string;
  21069. /** @hidden */
  21070. _refractionMatrixName: string;
  21071. /** @hidden */
  21072. _defineLODRefractionAlpha: string;
  21073. /** @hidden */
  21074. _defineLinearSpecularRefraction: string;
  21075. /** @hidden */
  21076. _defineOppositeZ: string;
  21077. /** @hidden */
  21078. _cubeSamplerName: string;
  21079. /** @hidden */
  21080. _2DSamplerName: string;
  21081. /** @hidden */
  21082. _vRefractionMicrosurfaceInfosName: string;
  21083. /** @hidden */
  21084. _vRefractionInfosName: string;
  21085. private _scene;
  21086. /**
  21087. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21088. * Materials half opaque for instance using refraction could benefit from this control.
  21089. */
  21090. linkRefractionWithTransparency: boolean;
  21091. /**
  21092. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21093. */
  21094. invertRefractionY: boolean;
  21095. /**
  21096. * Gets or sets the texture associated with the node
  21097. */
  21098. texture: Nullable<BaseTexture>;
  21099. /**
  21100. * Create a new RefractionBlock
  21101. * @param name defines the block name
  21102. */
  21103. constructor(name: string);
  21104. /**
  21105. * Gets the current class name
  21106. * @returns the class name
  21107. */
  21108. getClassName(): string;
  21109. /**
  21110. * Gets the intensity input component
  21111. */
  21112. get intensity(): NodeMaterialConnectionPoint;
  21113. /**
  21114. * Gets the index of refraction input component
  21115. */
  21116. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Gets the tint at distance input component
  21119. */
  21120. get tintAtDistance(): NodeMaterialConnectionPoint;
  21121. /**
  21122. * Gets the view input component
  21123. */
  21124. get view(): NodeMaterialConnectionPoint;
  21125. /**
  21126. * Gets the refraction object output component
  21127. */
  21128. get refraction(): NodeMaterialConnectionPoint;
  21129. /**
  21130. * Returns true if the block has a texture
  21131. */
  21132. get hasTexture(): boolean;
  21133. protected _getTexture(): Nullable<BaseTexture>;
  21134. autoConfigure(material: NodeMaterial): void;
  21135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21136. isReady(): boolean;
  21137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21138. /**
  21139. * Gets the main code of the block (fragment side)
  21140. * @param state current state of the node material building
  21141. * @returns the shader code
  21142. */
  21143. getCode(state: NodeMaterialBuildState): string;
  21144. protected _buildBlock(state: NodeMaterialBuildState): this;
  21145. protected _dumpPropertiesCode(): string;
  21146. serialize(): any;
  21147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21148. }
  21149. }
  21150. declare module BABYLON {
  21151. /**
  21152. * Base block used as input for post process
  21153. */
  21154. export class CurrentScreenBlock extends NodeMaterialBlock {
  21155. private _samplerName;
  21156. private _linearDefineName;
  21157. private _gammaDefineName;
  21158. private _mainUVName;
  21159. private _tempTextureRead;
  21160. /**
  21161. * Gets or sets the texture associated with the node
  21162. */
  21163. texture: Nullable<BaseTexture>;
  21164. /**
  21165. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21166. */
  21167. convertToGammaSpace: boolean;
  21168. /**
  21169. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21170. */
  21171. convertToLinearSpace: boolean;
  21172. /**
  21173. * Create a new CurrentScreenBlock
  21174. * @param name defines the block name
  21175. */
  21176. constructor(name: string);
  21177. /**
  21178. * Gets the current class name
  21179. * @returns the class name
  21180. */
  21181. getClassName(): string;
  21182. /**
  21183. * Gets the uv input component
  21184. */
  21185. get uv(): NodeMaterialConnectionPoint;
  21186. /**
  21187. * Gets the rgba output component
  21188. */
  21189. get rgba(): NodeMaterialConnectionPoint;
  21190. /**
  21191. * Gets the rgb output component
  21192. */
  21193. get rgb(): NodeMaterialConnectionPoint;
  21194. /**
  21195. * Gets the r output component
  21196. */
  21197. get r(): NodeMaterialConnectionPoint;
  21198. /**
  21199. * Gets the g output component
  21200. */
  21201. get g(): NodeMaterialConnectionPoint;
  21202. /**
  21203. * Gets the b output component
  21204. */
  21205. get b(): NodeMaterialConnectionPoint;
  21206. /**
  21207. * Gets the a output component
  21208. */
  21209. get a(): NodeMaterialConnectionPoint;
  21210. /**
  21211. * Initialize the block and prepare the context for build
  21212. * @param state defines the state that will be used for the build
  21213. */
  21214. initialize(state: NodeMaterialBuildState): void;
  21215. get target(): NodeMaterialBlockTargets;
  21216. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21217. isReady(): boolean;
  21218. private _injectVertexCode;
  21219. private _writeTextureRead;
  21220. private _writeOutput;
  21221. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21222. serialize(): any;
  21223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21224. }
  21225. }
  21226. declare module BABYLON {
  21227. /**
  21228. * Base block used for the particle texture
  21229. */
  21230. export class ParticleTextureBlock extends NodeMaterialBlock {
  21231. private _samplerName;
  21232. private _linearDefineName;
  21233. private _gammaDefineName;
  21234. private _tempTextureRead;
  21235. /**
  21236. * Gets or sets the texture associated with the node
  21237. */
  21238. texture: Nullable<BaseTexture>;
  21239. /**
  21240. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21241. */
  21242. convertToGammaSpace: boolean;
  21243. /**
  21244. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21245. */
  21246. convertToLinearSpace: boolean;
  21247. /**
  21248. * Create a new ParticleTextureBlock
  21249. * @param name defines the block name
  21250. */
  21251. constructor(name: string);
  21252. /**
  21253. * Gets the current class name
  21254. * @returns the class name
  21255. */
  21256. getClassName(): string;
  21257. /**
  21258. * Gets the uv input component
  21259. */
  21260. get uv(): NodeMaterialConnectionPoint;
  21261. /**
  21262. * Gets the rgba output component
  21263. */
  21264. get rgba(): NodeMaterialConnectionPoint;
  21265. /**
  21266. * Gets the rgb output component
  21267. */
  21268. get rgb(): NodeMaterialConnectionPoint;
  21269. /**
  21270. * Gets the r output component
  21271. */
  21272. get r(): NodeMaterialConnectionPoint;
  21273. /**
  21274. * Gets the g output component
  21275. */
  21276. get g(): NodeMaterialConnectionPoint;
  21277. /**
  21278. * Gets the b output component
  21279. */
  21280. get b(): NodeMaterialConnectionPoint;
  21281. /**
  21282. * Gets the a output component
  21283. */
  21284. get a(): NodeMaterialConnectionPoint;
  21285. /**
  21286. * Initialize the block and prepare the context for build
  21287. * @param state defines the state that will be used for the build
  21288. */
  21289. initialize(state: NodeMaterialBuildState): void;
  21290. autoConfigure(material: NodeMaterial): void;
  21291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21292. isReady(): boolean;
  21293. private _writeOutput;
  21294. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21295. serialize(): any;
  21296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21297. }
  21298. }
  21299. declare module BABYLON {
  21300. /**
  21301. * Class used to store shared data between 2 NodeMaterialBuildState
  21302. */
  21303. export class NodeMaterialBuildStateSharedData {
  21304. /**
  21305. * Gets the list of emitted varyings
  21306. */
  21307. temps: string[];
  21308. /**
  21309. * Gets the list of emitted varyings
  21310. */
  21311. varyings: string[];
  21312. /**
  21313. * Gets the varying declaration string
  21314. */
  21315. varyingDeclaration: string;
  21316. /**
  21317. * Input blocks
  21318. */
  21319. inputBlocks: InputBlock[];
  21320. /**
  21321. * Input blocks
  21322. */
  21323. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21324. /**
  21325. * Bindable blocks (Blocks that need to set data to the effect)
  21326. */
  21327. bindableBlocks: NodeMaterialBlock[];
  21328. /**
  21329. * List of blocks that can provide a compilation fallback
  21330. */
  21331. blocksWithFallbacks: NodeMaterialBlock[];
  21332. /**
  21333. * List of blocks that can provide a define update
  21334. */
  21335. blocksWithDefines: NodeMaterialBlock[];
  21336. /**
  21337. * List of blocks that can provide a repeatable content
  21338. */
  21339. repeatableContentBlocks: NodeMaterialBlock[];
  21340. /**
  21341. * List of blocks that can provide a dynamic list of uniforms
  21342. */
  21343. dynamicUniformBlocks: NodeMaterialBlock[];
  21344. /**
  21345. * List of blocks that can block the isReady function for the material
  21346. */
  21347. blockingBlocks: NodeMaterialBlock[];
  21348. /**
  21349. * Gets the list of animated inputs
  21350. */
  21351. animatedInputs: InputBlock[];
  21352. /**
  21353. * Build Id used to avoid multiple recompilations
  21354. */
  21355. buildId: number;
  21356. /** List of emitted variables */
  21357. variableNames: {
  21358. [key: string]: number;
  21359. };
  21360. /** List of emitted defines */
  21361. defineNames: {
  21362. [key: string]: number;
  21363. };
  21364. /** Should emit comments? */
  21365. emitComments: boolean;
  21366. /** Emit build activity */
  21367. verbose: boolean;
  21368. /** Gets or sets the hosting scene */
  21369. scene: Scene;
  21370. /**
  21371. * Gets the compilation hints emitted at compilation time
  21372. */
  21373. hints: {
  21374. needWorldViewMatrix: boolean;
  21375. needWorldViewProjectionMatrix: boolean;
  21376. needAlphaBlending: boolean;
  21377. needAlphaTesting: boolean;
  21378. };
  21379. /**
  21380. * List of compilation checks
  21381. */
  21382. checks: {
  21383. emitVertex: boolean;
  21384. emitFragment: boolean;
  21385. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21386. };
  21387. /**
  21388. * Is vertex program allowed to be empty?
  21389. */
  21390. allowEmptyVertexProgram: boolean;
  21391. /** Creates a new shared data */
  21392. constructor();
  21393. /**
  21394. * Emits console errors and exceptions if there is a failing check
  21395. */
  21396. emitErrors(): void;
  21397. }
  21398. }
  21399. declare module BABYLON {
  21400. /**
  21401. * Class used to store node based material build state
  21402. */
  21403. export class NodeMaterialBuildState {
  21404. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21405. supportUniformBuffers: boolean;
  21406. /**
  21407. * Gets the list of emitted attributes
  21408. */
  21409. attributes: string[];
  21410. /**
  21411. * Gets the list of emitted uniforms
  21412. */
  21413. uniforms: string[];
  21414. /**
  21415. * Gets the list of emitted constants
  21416. */
  21417. constants: string[];
  21418. /**
  21419. * Gets the list of emitted samplers
  21420. */
  21421. samplers: string[];
  21422. /**
  21423. * Gets the list of emitted functions
  21424. */
  21425. functions: {
  21426. [key: string]: string;
  21427. };
  21428. /**
  21429. * Gets the list of emitted extensions
  21430. */
  21431. extensions: {
  21432. [key: string]: string;
  21433. };
  21434. /**
  21435. * Gets the target of the compilation state
  21436. */
  21437. target: NodeMaterialBlockTargets;
  21438. /**
  21439. * Gets the list of emitted counters
  21440. */
  21441. counters: {
  21442. [key: string]: number;
  21443. };
  21444. /**
  21445. * Shared data between multiple NodeMaterialBuildState instances
  21446. */
  21447. sharedData: NodeMaterialBuildStateSharedData;
  21448. /** @hidden */
  21449. _vertexState: NodeMaterialBuildState;
  21450. /** @hidden */
  21451. _attributeDeclaration: string;
  21452. /** @hidden */
  21453. _uniformDeclaration: string;
  21454. /** @hidden */
  21455. _constantDeclaration: string;
  21456. /** @hidden */
  21457. _samplerDeclaration: string;
  21458. /** @hidden */
  21459. _varyingTransfer: string;
  21460. /** @hidden */
  21461. _injectAtEnd: string;
  21462. private _repeatableContentAnchorIndex;
  21463. /** @hidden */
  21464. _builtCompilationString: string;
  21465. /**
  21466. * Gets the emitted compilation strings
  21467. */
  21468. compilationString: string;
  21469. /**
  21470. * Finalize the compilation strings
  21471. * @param state defines the current compilation state
  21472. */
  21473. finalize(state: NodeMaterialBuildState): void;
  21474. /** @hidden */
  21475. get _repeatableContentAnchor(): string;
  21476. /** @hidden */
  21477. _getFreeVariableName(prefix: string): string;
  21478. /** @hidden */
  21479. _getFreeDefineName(prefix: string): string;
  21480. /** @hidden */
  21481. _excludeVariableName(name: string): void;
  21482. /** @hidden */
  21483. _emit2DSampler(name: string): void;
  21484. /** @hidden */
  21485. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21486. /** @hidden */
  21487. _emitExtension(name: string, extension: string, define?: string): void;
  21488. /** @hidden */
  21489. _emitFunction(name: string, code: string, comments: string): void;
  21490. /** @hidden */
  21491. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21492. replaceStrings?: {
  21493. search: RegExp;
  21494. replace: string;
  21495. }[];
  21496. repeatKey?: string;
  21497. }): string;
  21498. /** @hidden */
  21499. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21500. repeatKey?: string;
  21501. removeAttributes?: boolean;
  21502. removeUniforms?: boolean;
  21503. removeVaryings?: boolean;
  21504. removeIfDef?: boolean;
  21505. replaceStrings?: {
  21506. search: RegExp;
  21507. replace: string;
  21508. }[];
  21509. }, storeKey?: string): void;
  21510. /** @hidden */
  21511. _registerTempVariable(name: string): boolean;
  21512. /** @hidden */
  21513. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21514. /** @hidden */
  21515. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21516. /** @hidden */
  21517. _emitFloat(value: number): string;
  21518. }
  21519. }
  21520. declare module BABYLON {
  21521. /**
  21522. * Helper class used to generate session unique ID
  21523. */
  21524. export class UniqueIdGenerator {
  21525. private static _UniqueIdCounter;
  21526. /**
  21527. * Gets an unique (relatively to the current scene) Id
  21528. */
  21529. static get UniqueId(): number;
  21530. }
  21531. }
  21532. declare module BABYLON {
  21533. /**
  21534. * Defines a block that can be used inside a node based material
  21535. */
  21536. export class NodeMaterialBlock {
  21537. private _buildId;
  21538. private _buildTarget;
  21539. private _target;
  21540. private _isFinalMerger;
  21541. private _isInput;
  21542. private _name;
  21543. protected _isUnique: boolean;
  21544. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21545. inputsAreExclusive: boolean;
  21546. /** @hidden */
  21547. _codeVariableName: string;
  21548. /** @hidden */
  21549. _inputs: NodeMaterialConnectionPoint[];
  21550. /** @hidden */
  21551. _outputs: NodeMaterialConnectionPoint[];
  21552. /** @hidden */
  21553. _preparationId: number;
  21554. /**
  21555. * Gets the name of the block
  21556. */
  21557. get name(): string;
  21558. /**
  21559. * Sets the name of the block. Will check if the name is valid.
  21560. */
  21561. set name(newName: string);
  21562. /**
  21563. * Gets or sets the unique id of the node
  21564. */
  21565. uniqueId: number;
  21566. /**
  21567. * Gets or sets the comments associated with this block
  21568. */
  21569. comments: string;
  21570. /**
  21571. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21572. */
  21573. get isUnique(): boolean;
  21574. /**
  21575. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21576. */
  21577. get isFinalMerger(): boolean;
  21578. /**
  21579. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21580. */
  21581. get isInput(): boolean;
  21582. /**
  21583. * Gets or sets the build Id
  21584. */
  21585. get buildId(): number;
  21586. set buildId(value: number);
  21587. /**
  21588. * Gets or sets the target of the block
  21589. */
  21590. get target(): NodeMaterialBlockTargets;
  21591. set target(value: NodeMaterialBlockTargets);
  21592. /**
  21593. * Gets the list of input points
  21594. */
  21595. get inputs(): NodeMaterialConnectionPoint[];
  21596. /** Gets the list of output points */
  21597. get outputs(): NodeMaterialConnectionPoint[];
  21598. /**
  21599. * Find an input by its name
  21600. * @param name defines the name of the input to look for
  21601. * @returns the input or null if not found
  21602. */
  21603. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21604. /**
  21605. * Find an output by its name
  21606. * @param name defines the name of the outputto look for
  21607. * @returns the output or null if not found
  21608. */
  21609. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21610. /**
  21611. * Creates a new NodeMaterialBlock
  21612. * @param name defines the block name
  21613. * @param target defines the target of that block (Vertex by default)
  21614. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21615. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21616. */
  21617. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21618. /**
  21619. * Initialize the block and prepare the context for build
  21620. * @param state defines the state that will be used for the build
  21621. */
  21622. initialize(state: NodeMaterialBuildState): void;
  21623. /**
  21624. * Bind data to effect. Will only be called for blocks with isBindable === true
  21625. * @param effect defines the effect to bind data to
  21626. * @param nodeMaterial defines the hosting NodeMaterial
  21627. * @param mesh defines the mesh that will be rendered
  21628. * @param subMesh defines the submesh that will be rendered
  21629. */
  21630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21631. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21632. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21633. protected _writeFloat(value: number): string;
  21634. /**
  21635. * Gets the current class name e.g. "NodeMaterialBlock"
  21636. * @returns the class name
  21637. */
  21638. getClassName(): string;
  21639. /**
  21640. * Register a new input. Must be called inside a block constructor
  21641. * @param name defines the connection point name
  21642. * @param type defines the connection point type
  21643. * @param isOptional defines a boolean indicating that this input can be omitted
  21644. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21645. * @param point an already created connection point. If not provided, create a new one
  21646. * @returns the current block
  21647. */
  21648. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21649. /**
  21650. * Register a new output. Must be called inside a block constructor
  21651. * @param name defines the connection point name
  21652. * @param type defines the connection point type
  21653. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21654. * @param point an already created connection point. If not provided, create a new one
  21655. * @returns the current block
  21656. */
  21657. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21658. /**
  21659. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21660. * @param forOutput defines an optional connection point to check compatibility with
  21661. * @returns the first available input or null
  21662. */
  21663. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21664. /**
  21665. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21666. * @param forBlock defines an optional block to check compatibility with
  21667. * @returns the first available input or null
  21668. */
  21669. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21670. /**
  21671. * Gets the sibling of the given output
  21672. * @param current defines the current output
  21673. * @returns the next output in the list or null
  21674. */
  21675. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21676. /**
  21677. * Connect current block with another block
  21678. * @param other defines the block to connect with
  21679. * @param options define the various options to help pick the right connections
  21680. * @returns the current block
  21681. */
  21682. connectTo(other: NodeMaterialBlock, options?: {
  21683. input?: string;
  21684. output?: string;
  21685. outputSwizzle?: string;
  21686. }): this | undefined;
  21687. protected _buildBlock(state: NodeMaterialBuildState): void;
  21688. /**
  21689. * Add uniforms, samplers and uniform buffers at compilation time
  21690. * @param state defines the state to update
  21691. * @param nodeMaterial defines the node material requesting the update
  21692. * @param defines defines the material defines to update
  21693. * @param uniformBuffers defines the list of uniform buffer names
  21694. */
  21695. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21696. /**
  21697. * Add potential fallbacks if shader compilation fails
  21698. * @param mesh defines the mesh to be rendered
  21699. * @param fallbacks defines the current prioritized list of fallbacks
  21700. */
  21701. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21702. /**
  21703. * Initialize defines for shader compilation
  21704. * @param mesh defines the mesh to be rendered
  21705. * @param nodeMaterial defines the node material requesting the update
  21706. * @param defines defines the material defines to update
  21707. * @param useInstances specifies that instances should be used
  21708. */
  21709. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21710. /**
  21711. * Update defines for shader compilation
  21712. * @param mesh defines the mesh to be rendered
  21713. * @param nodeMaterial defines the node material requesting the update
  21714. * @param defines defines the material defines to update
  21715. * @param useInstances specifies that instances should be used
  21716. * @param subMesh defines which submesh to render
  21717. */
  21718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21719. /**
  21720. * Lets the block try to connect some inputs automatically
  21721. * @param material defines the hosting NodeMaterial
  21722. */
  21723. autoConfigure(material: NodeMaterial): void;
  21724. /**
  21725. * Function called when a block is declared as repeatable content generator
  21726. * @param vertexShaderState defines the current compilation state for the vertex shader
  21727. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21728. * @param mesh defines the mesh to be rendered
  21729. * @param defines defines the material defines to update
  21730. */
  21731. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21732. /**
  21733. * Checks if the block is ready
  21734. * @param mesh defines the mesh to be rendered
  21735. * @param nodeMaterial defines the node material requesting the update
  21736. * @param defines defines the material defines to update
  21737. * @param useInstances specifies that instances should be used
  21738. * @returns true if the block is ready
  21739. */
  21740. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21741. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21742. private _processBuild;
  21743. /**
  21744. * Validates the new name for the block node.
  21745. * @param newName the new name to be given to the node.
  21746. * @returns false if the name is a reserve word, else true.
  21747. */
  21748. validateBlockName(newName: string): boolean;
  21749. /**
  21750. * Compile the current node and generate the shader code
  21751. * @param state defines the current compilation state (uniforms, samplers, current string)
  21752. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21753. * @returns true if already built
  21754. */
  21755. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21756. protected _inputRename(name: string): string;
  21757. protected _outputRename(name: string): string;
  21758. protected _dumpPropertiesCode(): string;
  21759. /** @hidden */
  21760. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21761. /** @hidden */
  21762. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21763. /**
  21764. * Clone the current block to a new identical block
  21765. * @param scene defines the hosting scene
  21766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21767. * @returns a copy of the current block
  21768. */
  21769. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21770. /**
  21771. * Serializes this block in a JSON representation
  21772. * @returns the serialized block object
  21773. */
  21774. serialize(): any;
  21775. /** @hidden */
  21776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21777. private _deserializePortDisplayNamesAndExposedOnFrame;
  21778. /**
  21779. * Release resources
  21780. */
  21781. dispose(): void;
  21782. }
  21783. }
  21784. declare module BABYLON {
  21785. /**
  21786. * Base class of materials working in push mode in babylon JS
  21787. * @hidden
  21788. */
  21789. export class PushMaterial extends Material {
  21790. protected _activeEffect: Effect;
  21791. protected _normalMatrix: Matrix;
  21792. constructor(name: string, scene: Scene);
  21793. getEffect(): Effect;
  21794. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21795. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21796. /**
  21797. * Binds the given world matrix to the active effect
  21798. *
  21799. * @param world the matrix to bind
  21800. */
  21801. bindOnlyWorldMatrix(world: Matrix): void;
  21802. /**
  21803. * Binds the given normal matrix to the active effect
  21804. *
  21805. * @param normalMatrix the matrix to bind
  21806. */
  21807. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21808. bind(world: Matrix, mesh?: Mesh): void;
  21809. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21810. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21811. }
  21812. }
  21813. declare module BABYLON {
  21814. /**
  21815. * Root class for all node material optimizers
  21816. */
  21817. export class NodeMaterialOptimizer {
  21818. /**
  21819. * Function used to optimize a NodeMaterial graph
  21820. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21821. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21822. */
  21823. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21824. }
  21825. }
  21826. declare module BABYLON {
  21827. /**
  21828. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21829. */
  21830. export class TransformBlock extends NodeMaterialBlock {
  21831. /**
  21832. * Defines the value to use to complement W value to transform it to a Vector4
  21833. */
  21834. complementW: number;
  21835. /**
  21836. * Defines the value to use to complement z value to transform it to a Vector4
  21837. */
  21838. complementZ: number;
  21839. /**
  21840. * Creates a new TransformBlock
  21841. * @param name defines the block name
  21842. */
  21843. constructor(name: string);
  21844. /**
  21845. * Gets the current class name
  21846. * @returns the class name
  21847. */
  21848. getClassName(): string;
  21849. /**
  21850. * Gets the vector input
  21851. */
  21852. get vector(): NodeMaterialConnectionPoint;
  21853. /**
  21854. * Gets the output component
  21855. */
  21856. get output(): NodeMaterialConnectionPoint;
  21857. /**
  21858. * Gets the xyz output component
  21859. */
  21860. get xyz(): NodeMaterialConnectionPoint;
  21861. /**
  21862. * Gets the matrix transform input
  21863. */
  21864. get transform(): NodeMaterialConnectionPoint;
  21865. protected _buildBlock(state: NodeMaterialBuildState): this;
  21866. /**
  21867. * Update defines for shader compilation
  21868. * @param mesh defines the mesh to be rendered
  21869. * @param nodeMaterial defines the node material requesting the update
  21870. * @param defines defines the material defines to update
  21871. * @param useInstances specifies that instances should be used
  21872. * @param subMesh defines which submesh to render
  21873. */
  21874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21875. serialize(): any;
  21876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21877. protected _dumpPropertiesCode(): string;
  21878. }
  21879. }
  21880. declare module BABYLON {
  21881. /**
  21882. * Block used to output the vertex position
  21883. */
  21884. export class VertexOutputBlock extends NodeMaterialBlock {
  21885. /**
  21886. * Creates a new VertexOutputBlock
  21887. * @param name defines the block name
  21888. */
  21889. constructor(name: string);
  21890. /**
  21891. * Gets the current class name
  21892. * @returns the class name
  21893. */
  21894. getClassName(): string;
  21895. /**
  21896. * Gets the vector input component
  21897. */
  21898. get vector(): NodeMaterialConnectionPoint;
  21899. protected _buildBlock(state: NodeMaterialBuildState): this;
  21900. }
  21901. }
  21902. declare module BABYLON {
  21903. /**
  21904. * Block used to output the final color
  21905. */
  21906. export class FragmentOutputBlock extends NodeMaterialBlock {
  21907. /**
  21908. * Create a new FragmentOutputBlock
  21909. * @param name defines the block name
  21910. */
  21911. constructor(name: string);
  21912. /**
  21913. * Gets the current class name
  21914. * @returns the class name
  21915. */
  21916. getClassName(): string;
  21917. /**
  21918. * Gets the rgba input component
  21919. */
  21920. get rgba(): NodeMaterialConnectionPoint;
  21921. /**
  21922. * Gets the rgb input component
  21923. */
  21924. get rgb(): NodeMaterialConnectionPoint;
  21925. /**
  21926. * Gets the a input component
  21927. */
  21928. get a(): NodeMaterialConnectionPoint;
  21929. protected _buildBlock(state: NodeMaterialBuildState): this;
  21930. }
  21931. }
  21932. declare module BABYLON {
  21933. /**
  21934. * Block used for the particle ramp gradient section
  21935. */
  21936. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21937. /**
  21938. * Create a new ParticleRampGradientBlock
  21939. * @param name defines the block name
  21940. */
  21941. constructor(name: string);
  21942. /**
  21943. * Gets the current class name
  21944. * @returns the class name
  21945. */
  21946. getClassName(): string;
  21947. /**
  21948. * Gets the color input component
  21949. */
  21950. get color(): NodeMaterialConnectionPoint;
  21951. /**
  21952. * Gets the rampColor output component
  21953. */
  21954. get rampColor(): NodeMaterialConnectionPoint;
  21955. /**
  21956. * Initialize the block and prepare the context for build
  21957. * @param state defines the state that will be used for the build
  21958. */
  21959. initialize(state: NodeMaterialBuildState): void;
  21960. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21961. }
  21962. }
  21963. declare module BABYLON {
  21964. /**
  21965. * Block used for the particle blend multiply section
  21966. */
  21967. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21968. /**
  21969. * Create a new ParticleBlendMultiplyBlock
  21970. * @param name defines the block name
  21971. */
  21972. constructor(name: string);
  21973. /**
  21974. * Gets the current class name
  21975. * @returns the class name
  21976. */
  21977. getClassName(): string;
  21978. /**
  21979. * Gets the color input component
  21980. */
  21981. get color(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the alphaTexture input component
  21984. */
  21985. get alphaTexture(): NodeMaterialConnectionPoint;
  21986. /**
  21987. * Gets the alphaColor input component
  21988. */
  21989. get alphaColor(): NodeMaterialConnectionPoint;
  21990. /**
  21991. * Gets the blendColor output component
  21992. */
  21993. get blendColor(): NodeMaterialConnectionPoint;
  21994. /**
  21995. * Initialize the block and prepare the context for build
  21996. * @param state defines the state that will be used for the build
  21997. */
  21998. initialize(state: NodeMaterialBuildState): void;
  21999. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22000. }
  22001. }
  22002. declare module BABYLON {
  22003. /**
  22004. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22005. */
  22006. export class VectorMergerBlock extends NodeMaterialBlock {
  22007. /**
  22008. * Create a new VectorMergerBlock
  22009. * @param name defines the block name
  22010. */
  22011. constructor(name: string);
  22012. /**
  22013. * Gets the current class name
  22014. * @returns the class name
  22015. */
  22016. getClassName(): string;
  22017. /**
  22018. * Gets the xyz component (input)
  22019. */
  22020. get xyzIn(): NodeMaterialConnectionPoint;
  22021. /**
  22022. * Gets the xy component (input)
  22023. */
  22024. get xyIn(): NodeMaterialConnectionPoint;
  22025. /**
  22026. * Gets the x component (input)
  22027. */
  22028. get x(): NodeMaterialConnectionPoint;
  22029. /**
  22030. * Gets the y component (input)
  22031. */
  22032. get y(): NodeMaterialConnectionPoint;
  22033. /**
  22034. * Gets the z component (input)
  22035. */
  22036. get z(): NodeMaterialConnectionPoint;
  22037. /**
  22038. * Gets the w component (input)
  22039. */
  22040. get w(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the xyzw component (output)
  22043. */
  22044. get xyzw(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the xyz component (output)
  22047. */
  22048. get xyzOut(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the xy component (output)
  22051. */
  22052. get xyOut(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the xy component (output)
  22055. * @deprecated Please use xyOut instead.
  22056. */
  22057. get xy(): NodeMaterialConnectionPoint;
  22058. /**
  22059. * Gets the xyz component (output)
  22060. * @deprecated Please use xyzOut instead.
  22061. */
  22062. get xyz(): NodeMaterialConnectionPoint;
  22063. protected _buildBlock(state: NodeMaterialBuildState): this;
  22064. }
  22065. }
  22066. declare module BABYLON {
  22067. /**
  22068. * Block used to remap a float from a range to a new one
  22069. */
  22070. export class RemapBlock extends NodeMaterialBlock {
  22071. /**
  22072. * Gets or sets the source range
  22073. */
  22074. sourceRange: Vector2;
  22075. /**
  22076. * Gets or sets the target range
  22077. */
  22078. targetRange: Vector2;
  22079. /**
  22080. * Creates a new RemapBlock
  22081. * @param name defines the block name
  22082. */
  22083. constructor(name: string);
  22084. /**
  22085. * Gets the current class name
  22086. * @returns the class name
  22087. */
  22088. getClassName(): string;
  22089. /**
  22090. * Gets the input component
  22091. */
  22092. get input(): NodeMaterialConnectionPoint;
  22093. /**
  22094. * Gets the source min input component
  22095. */
  22096. get sourceMin(): NodeMaterialConnectionPoint;
  22097. /**
  22098. * Gets the source max input component
  22099. */
  22100. get sourceMax(): NodeMaterialConnectionPoint;
  22101. /**
  22102. * Gets the target min input component
  22103. */
  22104. get targetMin(): NodeMaterialConnectionPoint;
  22105. /**
  22106. * Gets the target max input component
  22107. */
  22108. get targetMax(): NodeMaterialConnectionPoint;
  22109. /**
  22110. * Gets the output component
  22111. */
  22112. get output(): NodeMaterialConnectionPoint;
  22113. protected _buildBlock(state: NodeMaterialBuildState): this;
  22114. protected _dumpPropertiesCode(): string;
  22115. serialize(): any;
  22116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22117. }
  22118. }
  22119. declare module BABYLON {
  22120. /**
  22121. * Block used to multiply 2 values
  22122. */
  22123. export class MultiplyBlock extends NodeMaterialBlock {
  22124. /**
  22125. * Creates a new MultiplyBlock
  22126. * @param name defines the block name
  22127. */
  22128. constructor(name: string);
  22129. /**
  22130. * Gets the current class name
  22131. * @returns the class name
  22132. */
  22133. getClassName(): string;
  22134. /**
  22135. * Gets the left operand input component
  22136. */
  22137. get left(): NodeMaterialConnectionPoint;
  22138. /**
  22139. * Gets the right operand input component
  22140. */
  22141. get right(): NodeMaterialConnectionPoint;
  22142. /**
  22143. * Gets the output component
  22144. */
  22145. get output(): NodeMaterialConnectionPoint;
  22146. protected _buildBlock(state: NodeMaterialBuildState): this;
  22147. }
  22148. }
  22149. declare module BABYLON {
  22150. /**
  22151. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22152. */
  22153. export class ColorSplitterBlock extends NodeMaterialBlock {
  22154. /**
  22155. * Create a new ColorSplitterBlock
  22156. * @param name defines the block name
  22157. */
  22158. constructor(name: string);
  22159. /**
  22160. * Gets the current class name
  22161. * @returns the class name
  22162. */
  22163. getClassName(): string;
  22164. /**
  22165. * Gets the rgba component (input)
  22166. */
  22167. get rgba(): NodeMaterialConnectionPoint;
  22168. /**
  22169. * Gets the rgb component (input)
  22170. */
  22171. get rgbIn(): NodeMaterialConnectionPoint;
  22172. /**
  22173. * Gets the rgb component (output)
  22174. */
  22175. get rgbOut(): NodeMaterialConnectionPoint;
  22176. /**
  22177. * Gets the r component (output)
  22178. */
  22179. get r(): NodeMaterialConnectionPoint;
  22180. /**
  22181. * Gets the g component (output)
  22182. */
  22183. get g(): NodeMaterialConnectionPoint;
  22184. /**
  22185. * Gets the b component (output)
  22186. */
  22187. get b(): NodeMaterialConnectionPoint;
  22188. /**
  22189. * Gets the a component (output)
  22190. */
  22191. get a(): NodeMaterialConnectionPoint;
  22192. protected _inputRename(name: string): string;
  22193. protected _outputRename(name: string): string;
  22194. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22195. }
  22196. }
  22197. declare module BABYLON {
  22198. /**
  22199. * Interface used to configure the node material editor
  22200. */
  22201. export interface INodeMaterialEditorOptions {
  22202. /** Define the URl to load node editor script */
  22203. editorURL?: string;
  22204. }
  22205. /** @hidden */
  22206. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22207. NORMAL: boolean;
  22208. TANGENT: boolean;
  22209. UV1: boolean;
  22210. /** BONES */
  22211. NUM_BONE_INFLUENCERS: number;
  22212. BonesPerMesh: number;
  22213. BONETEXTURE: boolean;
  22214. /** MORPH TARGETS */
  22215. MORPHTARGETS: boolean;
  22216. MORPHTARGETS_NORMAL: boolean;
  22217. MORPHTARGETS_TANGENT: boolean;
  22218. MORPHTARGETS_UV: boolean;
  22219. NUM_MORPH_INFLUENCERS: number;
  22220. /** IMAGE PROCESSING */
  22221. IMAGEPROCESSING: boolean;
  22222. VIGNETTE: boolean;
  22223. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22224. VIGNETTEBLENDMODEOPAQUE: boolean;
  22225. TONEMAPPING: boolean;
  22226. TONEMAPPING_ACES: boolean;
  22227. CONTRAST: boolean;
  22228. EXPOSURE: boolean;
  22229. COLORCURVES: boolean;
  22230. COLORGRADING: boolean;
  22231. COLORGRADING3D: boolean;
  22232. SAMPLER3DGREENDEPTH: boolean;
  22233. SAMPLER3DBGRMAP: boolean;
  22234. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22235. /** MISC. */
  22236. BUMPDIRECTUV: number;
  22237. constructor();
  22238. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22239. }
  22240. /**
  22241. * Class used to configure NodeMaterial
  22242. */
  22243. export interface INodeMaterialOptions {
  22244. /**
  22245. * Defines if blocks should emit comments
  22246. */
  22247. emitComments: boolean;
  22248. }
  22249. /**
  22250. * Class used to create a node based material built by assembling shader blocks
  22251. */
  22252. export class NodeMaterial extends PushMaterial {
  22253. private static _BuildIdGenerator;
  22254. private _options;
  22255. private _vertexCompilationState;
  22256. private _fragmentCompilationState;
  22257. private _sharedData;
  22258. private _buildId;
  22259. private _buildWasSuccessful;
  22260. private _cachedWorldViewMatrix;
  22261. private _cachedWorldViewProjectionMatrix;
  22262. private _optimizers;
  22263. private _animationFrame;
  22264. /** Define the Url to load node editor script */
  22265. static EditorURL: string;
  22266. /** Define the Url to load snippets */
  22267. static SnippetUrl: string;
  22268. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22269. static IgnoreTexturesAtLoadTime: boolean;
  22270. private BJSNODEMATERIALEDITOR;
  22271. /** Get the inspector from bundle or global */
  22272. private _getGlobalNodeMaterialEditor;
  22273. /**
  22274. * Snippet ID if the material was created from the snippet server
  22275. */
  22276. snippetId: string;
  22277. /**
  22278. * Gets or sets data used by visual editor
  22279. * @see https://nme.babylonjs.com
  22280. */
  22281. editorData: any;
  22282. /**
  22283. * 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)
  22284. */
  22285. ignoreAlpha: boolean;
  22286. /**
  22287. * Defines the maximum number of lights that can be used in the material
  22288. */
  22289. maxSimultaneousLights: number;
  22290. /**
  22291. * Observable raised when the material is built
  22292. */
  22293. onBuildObservable: Observable<NodeMaterial>;
  22294. /**
  22295. * Gets or sets the root nodes of the material vertex shader
  22296. */
  22297. _vertexOutputNodes: NodeMaterialBlock[];
  22298. /**
  22299. * Gets or sets the root nodes of the material fragment (pixel) shader
  22300. */
  22301. _fragmentOutputNodes: NodeMaterialBlock[];
  22302. /** Gets or sets options to control the node material overall behavior */
  22303. get options(): INodeMaterialOptions;
  22304. set options(options: INodeMaterialOptions);
  22305. /**
  22306. * Default configuration related to image processing available in the standard Material.
  22307. */
  22308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22309. /**
  22310. * Gets the image processing configuration used either in this material.
  22311. */
  22312. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22313. /**
  22314. * Sets the Default image processing configuration used either in the this material.
  22315. *
  22316. * If sets to null, the scene one is in use.
  22317. */
  22318. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22319. /**
  22320. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22321. */
  22322. attachedBlocks: NodeMaterialBlock[];
  22323. /**
  22324. * Specifies the mode of the node material
  22325. * @hidden
  22326. */
  22327. _mode: NodeMaterialModes;
  22328. /**
  22329. * Gets the mode property
  22330. */
  22331. get mode(): NodeMaterialModes;
  22332. /**
  22333. * Create a new node based material
  22334. * @param name defines the material name
  22335. * @param scene defines the hosting scene
  22336. * @param options defines creation option
  22337. */
  22338. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22339. /**
  22340. * Gets the current class name of the material e.g. "NodeMaterial"
  22341. * @returns the class name
  22342. */
  22343. getClassName(): string;
  22344. /**
  22345. * Keep track of the image processing observer to allow dispose and replace.
  22346. */
  22347. private _imageProcessingObserver;
  22348. /**
  22349. * Attaches a new image processing configuration to the Standard Material.
  22350. * @param configuration
  22351. */
  22352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22353. /**
  22354. * Get a block by its name
  22355. * @param name defines the name of the block to retrieve
  22356. * @returns the required block or null if not found
  22357. */
  22358. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22359. /**
  22360. * Get a block by its name
  22361. * @param predicate defines the predicate used to find the good candidate
  22362. * @returns the required block or null if not found
  22363. */
  22364. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22365. /**
  22366. * Get an input block by its name
  22367. * @param predicate defines the predicate used to find the good candidate
  22368. * @returns the required input block or null if not found
  22369. */
  22370. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22371. /**
  22372. * Gets the list of input blocks attached to this material
  22373. * @returns an array of InputBlocks
  22374. */
  22375. getInputBlocks(): InputBlock[];
  22376. /**
  22377. * Adds a new optimizer to the list of optimizers
  22378. * @param optimizer defines the optimizers to add
  22379. * @returns the current material
  22380. */
  22381. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22382. /**
  22383. * Remove an optimizer from the list of optimizers
  22384. * @param optimizer defines the optimizers to remove
  22385. * @returns the current material
  22386. */
  22387. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22388. /**
  22389. * Add a new block to the list of output nodes
  22390. * @param node defines the node to add
  22391. * @returns the current material
  22392. */
  22393. addOutputNode(node: NodeMaterialBlock): this;
  22394. /**
  22395. * Remove a block from the list of root nodes
  22396. * @param node defines the node to remove
  22397. * @returns the current material
  22398. */
  22399. removeOutputNode(node: NodeMaterialBlock): this;
  22400. private _addVertexOutputNode;
  22401. private _removeVertexOutputNode;
  22402. private _addFragmentOutputNode;
  22403. private _removeFragmentOutputNode;
  22404. /**
  22405. * Specifies if the material will require alpha blending
  22406. * @returns a boolean specifying if alpha blending is needed
  22407. */
  22408. needAlphaBlending(): boolean;
  22409. /**
  22410. * Specifies if this material should be rendered in alpha test mode
  22411. * @returns a boolean specifying if an alpha test is needed.
  22412. */
  22413. needAlphaTesting(): boolean;
  22414. private _initializeBlock;
  22415. private _resetDualBlocks;
  22416. /**
  22417. * Remove a block from the current node material
  22418. * @param block defines the block to remove
  22419. */
  22420. removeBlock(block: NodeMaterialBlock): void;
  22421. /**
  22422. * Build the material and generates the inner effect
  22423. * @param verbose defines if the build should log activity
  22424. */
  22425. build(verbose?: boolean): void;
  22426. /**
  22427. * Runs an otpimization phase to try to improve the shader code
  22428. */
  22429. optimize(): void;
  22430. private _prepareDefinesForAttributes;
  22431. /**
  22432. * Create a post process from the material
  22433. * @param camera The camera to apply the render pass to.
  22434. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22436. * @param engine The engine which the post process will be applied. (default: current engine)
  22437. * @param reusable If the post process can be reused on the same frame. (default: false)
  22438. * @param textureType Type of textures used when performing the post process. (default: 0)
  22439. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22440. * @returns the post process created
  22441. */
  22442. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22443. /**
  22444. * Create the post process effect from the material
  22445. * @param postProcess The post process to create the effect for
  22446. */
  22447. createEffectForPostProcess(postProcess: PostProcess): void;
  22448. private _createEffectOrPostProcess;
  22449. private _createEffectForParticles;
  22450. /**
  22451. * Create the effect to be used as the custom effect for a particle system
  22452. * @param particleSystem Particle system to create the effect for
  22453. * @param onCompiled defines a function to call when the effect creation is successful
  22454. * @param onError defines a function to call when the effect creation has failed
  22455. */
  22456. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22457. private _processDefines;
  22458. /**
  22459. * Get if the submesh is ready to be used and all its information available.
  22460. * Child classes can use it to update shaders
  22461. * @param mesh defines the mesh to check
  22462. * @param subMesh defines which submesh to check
  22463. * @param useInstances specifies that instances should be used
  22464. * @returns a boolean indicating that the submesh is ready or not
  22465. */
  22466. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22467. /**
  22468. * Get a string representing the shaders built by the current node graph
  22469. */
  22470. get compiledShaders(): string;
  22471. /**
  22472. * Binds the world matrix to the material
  22473. * @param world defines the world transformation matrix
  22474. */
  22475. bindOnlyWorldMatrix(world: Matrix): void;
  22476. /**
  22477. * Binds the submesh to this material by preparing the effect and shader to draw
  22478. * @param world defines the world transformation matrix
  22479. * @param mesh defines the mesh containing the submesh
  22480. * @param subMesh defines the submesh to bind the material to
  22481. */
  22482. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22483. /**
  22484. * Gets the active textures from the material
  22485. * @returns an array of textures
  22486. */
  22487. getActiveTextures(): BaseTexture[];
  22488. /**
  22489. * Gets the list of texture blocks
  22490. * @returns an array of texture blocks
  22491. */
  22492. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22493. /**
  22494. * Specifies if the material uses a texture
  22495. * @param texture defines the texture to check against the material
  22496. * @returns a boolean specifying if the material uses the texture
  22497. */
  22498. hasTexture(texture: BaseTexture): boolean;
  22499. /**
  22500. * Disposes the material
  22501. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22502. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22503. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22504. */
  22505. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22506. /** Creates the node editor window. */
  22507. private _createNodeEditor;
  22508. /**
  22509. * Launch the node material editor
  22510. * @param config Define the configuration of the editor
  22511. * @return a promise fulfilled when the node editor is visible
  22512. */
  22513. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22514. /**
  22515. * Clear the current material
  22516. */
  22517. clear(): void;
  22518. /**
  22519. * Clear the current material and set it to a default state
  22520. */
  22521. setToDefault(): void;
  22522. /**
  22523. * Clear the current material and set it to a default state for post process
  22524. */
  22525. setToDefaultPostProcess(): void;
  22526. /**
  22527. * Clear the current material and set it to a default state for particle
  22528. */
  22529. setToDefaultParticle(): void;
  22530. /**
  22531. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22532. * @param url defines the url to load from
  22533. * @returns a promise that will fullfil when the material is fully loaded
  22534. */
  22535. loadAsync(url: string): Promise<void>;
  22536. private _gatherBlocks;
  22537. /**
  22538. * Generate a string containing the code declaration required to create an equivalent of this material
  22539. * @returns a string
  22540. */
  22541. generateCode(): string;
  22542. /**
  22543. * Serializes this material in a JSON representation
  22544. * @returns the serialized material object
  22545. */
  22546. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22547. private _restoreConnections;
  22548. /**
  22549. * Clear the current graph and load a new one from a serialization object
  22550. * @param source defines the JSON representation of the material
  22551. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22552. * @param merge defines whether or not the source must be merged or replace the current content
  22553. */
  22554. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22555. /**
  22556. * Makes a duplicate of the current material.
  22557. * @param name - name to use for the new material.
  22558. */
  22559. clone(name: string): NodeMaterial;
  22560. /**
  22561. * Creates a node material from parsed material data
  22562. * @param source defines the JSON representation of the material
  22563. * @param scene defines the hosting scene
  22564. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22565. * @returns a new node material
  22566. */
  22567. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22568. /**
  22569. * Creates a node material from a snippet saved in a remote file
  22570. * @param name defines the name of the material to create
  22571. * @param url defines the url to load from
  22572. * @param scene defines the hosting scene
  22573. * @returns a promise that will resolve to the new node material
  22574. */
  22575. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22576. /**
  22577. * Creates a node material from a snippet saved by the node material editor
  22578. * @param snippetId defines the snippet to load
  22579. * @param scene defines the hosting scene
  22580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22581. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22582. * @returns a promise that will resolve to the new node material
  22583. */
  22584. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22585. /**
  22586. * Creates a new node material set to default basic configuration
  22587. * @param name defines the name of the material
  22588. * @param scene defines the hosting scene
  22589. * @returns a new NodeMaterial
  22590. */
  22591. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22592. }
  22593. }
  22594. declare module BABYLON {
  22595. /**
  22596. * Size options for a post process
  22597. */
  22598. export type PostProcessOptions = {
  22599. width: number;
  22600. height: number;
  22601. };
  22602. /**
  22603. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22604. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22605. */
  22606. export class PostProcess {
  22607. /**
  22608. * Gets or sets the unique id of the post process
  22609. */
  22610. uniqueId: number;
  22611. /** Name of the PostProcess. */
  22612. name: string;
  22613. /**
  22614. * Width of the texture to apply the post process on
  22615. */
  22616. width: number;
  22617. /**
  22618. * Height of the texture to apply the post process on
  22619. */
  22620. height: number;
  22621. /**
  22622. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22623. */
  22624. nodeMaterialSource: Nullable<NodeMaterial>;
  22625. /**
  22626. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22627. * @hidden
  22628. */
  22629. _outputTexture: Nullable<InternalTexture>;
  22630. /**
  22631. * Sampling mode used by the shader
  22632. * See https://doc.babylonjs.com/classes/3.1/texture
  22633. */
  22634. renderTargetSamplingMode: number;
  22635. /**
  22636. * Clear color to use when screen clearing
  22637. */
  22638. clearColor: Color4;
  22639. /**
  22640. * If the buffer needs to be cleared before applying the post process. (default: true)
  22641. * Should be set to false if shader will overwrite all previous pixels.
  22642. */
  22643. autoClear: boolean;
  22644. /**
  22645. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22646. */
  22647. alphaMode: number;
  22648. /**
  22649. * Sets the setAlphaBlendConstants of the babylon engine
  22650. */
  22651. alphaConstants: Color4;
  22652. /**
  22653. * Animations to be used for the post processing
  22654. */
  22655. animations: Animation[];
  22656. /**
  22657. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22658. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22659. */
  22660. enablePixelPerfectMode: boolean;
  22661. /**
  22662. * Force the postprocess to be applied without taking in account viewport
  22663. */
  22664. forceFullscreenViewport: boolean;
  22665. /**
  22666. * List of inspectable custom properties (used by the Inspector)
  22667. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22668. */
  22669. inspectableCustomProperties: IInspectable[];
  22670. /**
  22671. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22672. *
  22673. * | Value | Type | Description |
  22674. * | ----- | ----------------------------------- | ----------- |
  22675. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22676. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22677. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22678. *
  22679. */
  22680. scaleMode: number;
  22681. /**
  22682. * Force textures to be a power of two (default: false)
  22683. */
  22684. alwaysForcePOT: boolean;
  22685. private _samples;
  22686. /**
  22687. * Number of sample textures (default: 1)
  22688. */
  22689. get samples(): number;
  22690. set samples(n: number);
  22691. /**
  22692. * Modify the scale of the post process to be the same as the viewport (default: false)
  22693. */
  22694. adaptScaleToCurrentViewport: boolean;
  22695. private _camera;
  22696. protected _scene: Scene;
  22697. private _engine;
  22698. private _options;
  22699. private _reusable;
  22700. private _textureType;
  22701. private _textureFormat;
  22702. /**
  22703. * Smart array of input and output textures for the post process.
  22704. * @hidden
  22705. */
  22706. _textures: SmartArray<InternalTexture>;
  22707. /**
  22708. * The index in _textures that corresponds to the output texture.
  22709. * @hidden
  22710. */
  22711. _currentRenderTextureInd: number;
  22712. private _effect;
  22713. private _samplers;
  22714. private _fragmentUrl;
  22715. private _vertexUrl;
  22716. private _parameters;
  22717. private _scaleRatio;
  22718. protected _indexParameters: any;
  22719. private _shareOutputWithPostProcess;
  22720. private _texelSize;
  22721. private _forcedOutputTexture;
  22722. /**
  22723. * Returns the fragment url or shader name used in the post process.
  22724. * @returns the fragment url or name in the shader store.
  22725. */
  22726. getEffectName(): string;
  22727. /**
  22728. * An event triggered when the postprocess is activated.
  22729. */
  22730. onActivateObservable: Observable<Camera>;
  22731. private _onActivateObserver;
  22732. /**
  22733. * A function that is added to the onActivateObservable
  22734. */
  22735. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22736. /**
  22737. * An event triggered when the postprocess changes its size.
  22738. */
  22739. onSizeChangedObservable: Observable<PostProcess>;
  22740. private _onSizeChangedObserver;
  22741. /**
  22742. * A function that is added to the onSizeChangedObservable
  22743. */
  22744. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22745. /**
  22746. * An event triggered when the postprocess applies its effect.
  22747. */
  22748. onApplyObservable: Observable<Effect>;
  22749. private _onApplyObserver;
  22750. /**
  22751. * A function that is added to the onApplyObservable
  22752. */
  22753. set onApply(callback: (effect: Effect) => void);
  22754. /**
  22755. * An event triggered before rendering the postprocess
  22756. */
  22757. onBeforeRenderObservable: Observable<Effect>;
  22758. private _onBeforeRenderObserver;
  22759. /**
  22760. * A function that is added to the onBeforeRenderObservable
  22761. */
  22762. set onBeforeRender(callback: (effect: Effect) => void);
  22763. /**
  22764. * An event triggered after rendering the postprocess
  22765. */
  22766. onAfterRenderObservable: Observable<Effect>;
  22767. private _onAfterRenderObserver;
  22768. /**
  22769. * A function that is added to the onAfterRenderObservable
  22770. */
  22771. set onAfterRender(callback: (efect: Effect) => void);
  22772. /**
  22773. * 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
  22774. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22775. */
  22776. get inputTexture(): InternalTexture;
  22777. set inputTexture(value: InternalTexture);
  22778. /**
  22779. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22780. * the only way to unset it is to use this function to restore its internal state
  22781. */
  22782. restoreDefaultInputTexture(): void;
  22783. /**
  22784. * Gets the camera which post process is applied to.
  22785. * @returns The camera the post process is applied to.
  22786. */
  22787. getCamera(): Camera;
  22788. /**
  22789. * Gets the texel size of the postprocess.
  22790. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22791. */
  22792. get texelSize(): Vector2;
  22793. /**
  22794. * Creates a new instance PostProcess
  22795. * @param name The name of the PostProcess.
  22796. * @param fragmentUrl The url of the fragment shader to be used.
  22797. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22798. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22799. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22800. * @param camera The camera to apply the render pass to.
  22801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22802. * @param engine The engine which the post process will be applied. (default: current engine)
  22803. * @param reusable If the post process can be reused on the same frame. (default: false)
  22804. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22805. * @param textureType Type of textures used when performing the post process. (default: 0)
  22806. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22807. * @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
  22808. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22809. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22810. */
  22811. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22812. /**
  22813. * Gets a string identifying the name of the class
  22814. * @returns "PostProcess" string
  22815. */
  22816. getClassName(): string;
  22817. /**
  22818. * Gets the engine which this post process belongs to.
  22819. * @returns The engine the post process was enabled with.
  22820. */
  22821. getEngine(): Engine;
  22822. /**
  22823. * The effect that is created when initializing the post process.
  22824. * @returns The created effect corresponding the the postprocess.
  22825. */
  22826. getEffect(): Effect;
  22827. /**
  22828. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22829. * @param postProcess The post process to share the output with.
  22830. * @returns This post process.
  22831. */
  22832. shareOutputWith(postProcess: PostProcess): PostProcess;
  22833. /**
  22834. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22835. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22836. */
  22837. useOwnOutput(): void;
  22838. /**
  22839. * Updates the effect with the current post process compile time values and recompiles the shader.
  22840. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22841. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22842. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22843. * @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
  22844. * @param onCompiled Called when the shader has been compiled.
  22845. * @param onError Called if there is an error when compiling a shader.
  22846. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22847. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22848. */
  22849. 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;
  22850. /**
  22851. * The post process is reusable if it can be used multiple times within one frame.
  22852. * @returns If the post process is reusable
  22853. */
  22854. isReusable(): boolean;
  22855. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22856. markTextureDirty(): void;
  22857. /**
  22858. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22859. * 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.
  22860. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22861. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22862. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22863. * @returns The target texture that was bound to be written to.
  22864. */
  22865. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22866. /**
  22867. * If the post process is supported.
  22868. */
  22869. get isSupported(): boolean;
  22870. /**
  22871. * The aspect ratio of the output texture.
  22872. */
  22873. get aspectRatio(): number;
  22874. /**
  22875. * Get a value indicating if the post-process is ready to be used
  22876. * @returns true if the post-process is ready (shader is compiled)
  22877. */
  22878. isReady(): boolean;
  22879. /**
  22880. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22881. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22882. */
  22883. apply(): Nullable<Effect>;
  22884. private _disposeTextures;
  22885. /**
  22886. * Disposes the post process.
  22887. * @param camera The camera to dispose the post process on.
  22888. */
  22889. dispose(camera?: Camera): void;
  22890. /**
  22891. * Serializes the particle system to a JSON object
  22892. * @returns the JSON object
  22893. */
  22894. serialize(): any;
  22895. /**
  22896. * Creates a material from parsed material data
  22897. * @param parsedPostProcess defines parsed post process data
  22898. * @param scene defines the hosting scene
  22899. * @param rootUrl defines the root URL to use to load textures
  22900. * @returns a new post process
  22901. */
  22902. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22903. }
  22904. }
  22905. declare module BABYLON {
  22906. /** @hidden */
  22907. export var kernelBlurVaryingDeclaration: {
  22908. name: string;
  22909. shader: string;
  22910. };
  22911. }
  22912. declare module BABYLON {
  22913. /** @hidden */
  22914. export var kernelBlurFragment: {
  22915. name: string;
  22916. shader: string;
  22917. };
  22918. }
  22919. declare module BABYLON {
  22920. /** @hidden */
  22921. export var kernelBlurFragment2: {
  22922. name: string;
  22923. shader: string;
  22924. };
  22925. }
  22926. declare module BABYLON {
  22927. /** @hidden */
  22928. export var kernelBlurPixelShader: {
  22929. name: string;
  22930. shader: string;
  22931. };
  22932. }
  22933. declare module BABYLON {
  22934. /** @hidden */
  22935. export var kernelBlurVertex: {
  22936. name: string;
  22937. shader: string;
  22938. };
  22939. }
  22940. declare module BABYLON {
  22941. /** @hidden */
  22942. export var kernelBlurVertexShader: {
  22943. name: string;
  22944. shader: string;
  22945. };
  22946. }
  22947. declare module BABYLON {
  22948. /**
  22949. * The Blur Post Process which blurs an image based on a kernel and direction.
  22950. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22951. */
  22952. export class BlurPostProcess extends PostProcess {
  22953. private blockCompilation;
  22954. protected _kernel: number;
  22955. protected _idealKernel: number;
  22956. protected _packedFloat: boolean;
  22957. private _staticDefines;
  22958. /** The direction in which to blur the image. */
  22959. direction: Vector2;
  22960. /**
  22961. * Sets the length in pixels of the blur sample region
  22962. */
  22963. set kernel(v: number);
  22964. /**
  22965. * Gets the length in pixels of the blur sample region
  22966. */
  22967. get kernel(): number;
  22968. /**
  22969. * Sets wether or not the blur needs to unpack/repack floats
  22970. */
  22971. set packedFloat(v: boolean);
  22972. /**
  22973. * Gets wether or not the blur is unpacking/repacking floats
  22974. */
  22975. get packedFloat(): boolean;
  22976. /**
  22977. * Gets a string identifying the name of the class
  22978. * @returns "BlurPostProcess" string
  22979. */
  22980. getClassName(): string;
  22981. /**
  22982. * Creates a new instance BlurPostProcess
  22983. * @param name The name of the effect.
  22984. * @param direction The direction in which to blur the image.
  22985. * @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.
  22986. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22987. * @param camera The camera to apply the render pass to.
  22988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22989. * @param engine The engine which the post process will be applied. (default: current engine)
  22990. * @param reusable If the post process can be reused on the same frame. (default: false)
  22991. * @param textureType Type of textures used when performing the post process. (default: 0)
  22992. * @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)
  22993. */
  22994. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22995. /**
  22996. * Updates the effect with the current post process compile time values and recompiles the shader.
  22997. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22998. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22999. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23000. * @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
  23001. * @param onCompiled Called when the shader has been compiled.
  23002. * @param onError Called if there is an error when compiling a shader.
  23003. */
  23004. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23005. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23006. /**
  23007. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23008. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23009. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23010. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23011. * The gaps between physical kernels are compensated for in the weighting of the samples
  23012. * @param idealKernel Ideal blur kernel.
  23013. * @return Nearest best kernel.
  23014. */
  23015. protected _nearestBestKernel(idealKernel: number): number;
  23016. /**
  23017. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23018. * @param x The point on the Gaussian distribution to sample.
  23019. * @return the value of the Gaussian function at x.
  23020. */
  23021. protected _gaussianWeight(x: number): number;
  23022. /**
  23023. * Generates a string that can be used as a floating point number in GLSL.
  23024. * @param x Value to print.
  23025. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23026. * @return GLSL float string.
  23027. */
  23028. protected _glslFloat(x: number, decimalFigures?: number): string;
  23029. /** @hidden */
  23030. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23031. }
  23032. }
  23033. declare module BABYLON {
  23034. /**
  23035. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23036. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23037. * You can then easily use it as a reflectionTexture on a flat surface.
  23038. * In case the surface is not a plane, please consider relying on reflection probes.
  23039. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23040. */
  23041. export class MirrorTexture extends RenderTargetTexture {
  23042. private scene;
  23043. /**
  23044. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23045. * 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.
  23046. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23047. */
  23048. mirrorPlane: Plane;
  23049. /**
  23050. * Define the blur ratio used to blur the reflection if needed.
  23051. */
  23052. set blurRatio(value: number);
  23053. get blurRatio(): number;
  23054. /**
  23055. * Define the adaptive blur kernel used to blur the reflection if needed.
  23056. * This will autocompute the closest best match for the `blurKernel`
  23057. */
  23058. set adaptiveBlurKernel(value: number);
  23059. /**
  23060. * Define the blur kernel used to blur the reflection if needed.
  23061. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23062. */
  23063. set blurKernel(value: number);
  23064. /**
  23065. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23066. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23067. */
  23068. set blurKernelX(value: number);
  23069. get blurKernelX(): number;
  23070. /**
  23071. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23072. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23073. */
  23074. set blurKernelY(value: number);
  23075. get blurKernelY(): number;
  23076. private _autoComputeBlurKernel;
  23077. protected _onRatioRescale(): void;
  23078. private _updateGammaSpace;
  23079. private _imageProcessingConfigChangeObserver;
  23080. private _transformMatrix;
  23081. private _mirrorMatrix;
  23082. private _savedViewMatrix;
  23083. private _blurX;
  23084. private _blurY;
  23085. private _adaptiveBlurKernel;
  23086. private _blurKernelX;
  23087. private _blurKernelY;
  23088. private _blurRatio;
  23089. /**
  23090. * Instantiates a Mirror Texture.
  23091. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23092. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23093. * You can then easily use it as a reflectionTexture on a flat surface.
  23094. * In case the surface is not a plane, please consider relying on reflection probes.
  23095. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23096. * @param name
  23097. * @param size
  23098. * @param scene
  23099. * @param generateMipMaps
  23100. * @param type
  23101. * @param samplingMode
  23102. * @param generateDepthBuffer
  23103. */
  23104. constructor(name: string, size: number | {
  23105. width: number;
  23106. height: number;
  23107. } | {
  23108. ratio: number;
  23109. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23110. private _preparePostProcesses;
  23111. /**
  23112. * Clone the mirror texture.
  23113. * @returns the cloned texture
  23114. */
  23115. clone(): MirrorTexture;
  23116. /**
  23117. * Serialize the texture to a JSON representation you could use in Parse later on
  23118. * @returns the serialized JSON representation
  23119. */
  23120. serialize(): any;
  23121. /**
  23122. * Dispose the texture and release its associated resources.
  23123. */
  23124. dispose(): void;
  23125. }
  23126. }
  23127. declare module BABYLON {
  23128. /**
  23129. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23130. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23131. */
  23132. export class Texture extends BaseTexture {
  23133. /**
  23134. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23135. */
  23136. static SerializeBuffers: boolean;
  23137. /** @hidden */
  23138. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23139. /** @hidden */
  23140. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23141. /** @hidden */
  23142. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23143. /** nearest is mag = nearest and min = nearest and mip = linear */
  23144. static readonly NEAREST_SAMPLINGMODE: number;
  23145. /** nearest is mag = nearest and min = nearest and mip = linear */
  23146. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23147. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23148. static readonly BILINEAR_SAMPLINGMODE: number;
  23149. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23150. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23151. /** Trilinear is mag = linear and min = linear and mip = linear */
  23152. static readonly TRILINEAR_SAMPLINGMODE: number;
  23153. /** Trilinear is mag = linear and min = linear and mip = linear */
  23154. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23155. /** mag = nearest and min = nearest and mip = nearest */
  23156. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23157. /** mag = nearest and min = linear and mip = nearest */
  23158. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23159. /** mag = nearest and min = linear and mip = linear */
  23160. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23161. /** mag = nearest and min = linear and mip = none */
  23162. static readonly NEAREST_LINEAR: number;
  23163. /** mag = nearest and min = nearest and mip = none */
  23164. static readonly NEAREST_NEAREST: number;
  23165. /** mag = linear and min = nearest and mip = nearest */
  23166. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23167. /** mag = linear and min = nearest and mip = linear */
  23168. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23169. /** mag = linear and min = linear and mip = none */
  23170. static readonly LINEAR_LINEAR: number;
  23171. /** mag = linear and min = nearest and mip = none */
  23172. static readonly LINEAR_NEAREST: number;
  23173. /** Explicit coordinates mode */
  23174. static readonly EXPLICIT_MODE: number;
  23175. /** Spherical coordinates mode */
  23176. static readonly SPHERICAL_MODE: number;
  23177. /** Planar coordinates mode */
  23178. static readonly PLANAR_MODE: number;
  23179. /** Cubic coordinates mode */
  23180. static readonly CUBIC_MODE: number;
  23181. /** Projection coordinates mode */
  23182. static readonly PROJECTION_MODE: number;
  23183. /** Inverse Cubic coordinates mode */
  23184. static readonly SKYBOX_MODE: number;
  23185. /** Inverse Cubic coordinates mode */
  23186. static readonly INVCUBIC_MODE: number;
  23187. /** Equirectangular coordinates mode */
  23188. static readonly EQUIRECTANGULAR_MODE: number;
  23189. /** Equirectangular Fixed coordinates mode */
  23190. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23191. /** Equirectangular Fixed Mirrored coordinates mode */
  23192. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23193. /** Texture is not repeating outside of 0..1 UVs */
  23194. static readonly CLAMP_ADDRESSMODE: number;
  23195. /** Texture is repeating outside of 0..1 UVs */
  23196. static readonly WRAP_ADDRESSMODE: number;
  23197. /** Texture is repeating and mirrored */
  23198. static readonly MIRROR_ADDRESSMODE: number;
  23199. /**
  23200. * 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
  23201. */
  23202. static UseSerializedUrlIfAny: boolean;
  23203. /**
  23204. * Define the url of the texture.
  23205. */
  23206. url: Nullable<string>;
  23207. /**
  23208. * Define an offset on the texture to offset the u coordinates of the UVs
  23209. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23210. */
  23211. uOffset: number;
  23212. /**
  23213. * Define an offset on the texture to offset the v coordinates of the UVs
  23214. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23215. */
  23216. vOffset: number;
  23217. /**
  23218. * Define an offset on the texture to scale the u coordinates of the UVs
  23219. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23220. */
  23221. uScale: number;
  23222. /**
  23223. * Define an offset on the texture to scale the v coordinates of the UVs
  23224. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23225. */
  23226. vScale: number;
  23227. /**
  23228. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23229. * @see https://doc.babylonjs.com/how_to/more_materials
  23230. */
  23231. uAng: number;
  23232. /**
  23233. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23234. * @see https://doc.babylonjs.com/how_to/more_materials
  23235. */
  23236. vAng: number;
  23237. /**
  23238. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23239. * @see https://doc.babylonjs.com/how_to/more_materials
  23240. */
  23241. wAng: number;
  23242. /**
  23243. * Defines the center of rotation (U)
  23244. */
  23245. uRotationCenter: number;
  23246. /**
  23247. * Defines the center of rotation (V)
  23248. */
  23249. vRotationCenter: number;
  23250. /**
  23251. * Defines the center of rotation (W)
  23252. */
  23253. wRotationCenter: number;
  23254. /**
  23255. * Are mip maps generated for this texture or not.
  23256. */
  23257. get noMipmap(): boolean;
  23258. /**
  23259. * List of inspectable custom properties (used by the Inspector)
  23260. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23261. */
  23262. inspectableCustomProperties: Nullable<IInspectable[]>;
  23263. private _noMipmap;
  23264. /** @hidden */
  23265. _invertY: boolean;
  23266. private _rowGenerationMatrix;
  23267. private _cachedTextureMatrix;
  23268. private _projectionModeMatrix;
  23269. private _t0;
  23270. private _t1;
  23271. private _t2;
  23272. private _cachedUOffset;
  23273. private _cachedVOffset;
  23274. private _cachedUScale;
  23275. private _cachedVScale;
  23276. private _cachedUAng;
  23277. private _cachedVAng;
  23278. private _cachedWAng;
  23279. private _cachedProjectionMatrixId;
  23280. private _cachedCoordinatesMode;
  23281. /** @hidden */
  23282. protected _initialSamplingMode: number;
  23283. /** @hidden */
  23284. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23285. private _deleteBuffer;
  23286. protected _format: Nullable<number>;
  23287. private _delayedOnLoad;
  23288. private _delayedOnError;
  23289. private _mimeType?;
  23290. /**
  23291. * Observable triggered once the texture has been loaded.
  23292. */
  23293. onLoadObservable: Observable<Texture>;
  23294. protected _isBlocking: boolean;
  23295. /**
  23296. * Is the texture preventing material to render while loading.
  23297. * If false, a default texture will be used instead of the loading one during the preparation step.
  23298. */
  23299. set isBlocking(value: boolean);
  23300. get isBlocking(): boolean;
  23301. /**
  23302. * Get the current sampling mode associated with the texture.
  23303. */
  23304. get samplingMode(): number;
  23305. /**
  23306. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23307. */
  23308. get invertY(): boolean;
  23309. /**
  23310. * Instantiates a new texture.
  23311. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23312. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23313. * @param url defines the url of the picture to load as a texture
  23314. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23315. * @param noMipmap defines if the texture will require mip maps or not
  23316. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23317. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23318. * @param onLoad defines a callback triggered when the texture has been loaded
  23319. * @param onError defines a callback triggered when an error occurred during the loading session
  23320. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23321. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23322. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23323. * @param mimeType defines an optional mime type information
  23324. */
  23325. 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);
  23326. /**
  23327. * Update the url (and optional buffer) of this texture if url was null during construction.
  23328. * @param url the url of the texture
  23329. * @param buffer the buffer of the texture (defaults to null)
  23330. * @param onLoad callback called when the texture is loaded (defaults to null)
  23331. */
  23332. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23333. /**
  23334. * Finish the loading sequence of a texture flagged as delayed load.
  23335. * @hidden
  23336. */
  23337. delayLoad(): void;
  23338. private _prepareRowForTextureGeneration;
  23339. /**
  23340. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23341. * @returns the transform matrix of the texture.
  23342. */
  23343. getTextureMatrix(uBase?: number): Matrix;
  23344. /**
  23345. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23346. * @returns The reflection texture transform
  23347. */
  23348. getReflectionTextureMatrix(): Matrix;
  23349. /**
  23350. * Clones the texture.
  23351. * @returns the cloned texture
  23352. */
  23353. clone(): Texture;
  23354. /**
  23355. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23356. * @returns The JSON representation of the texture
  23357. */
  23358. serialize(): any;
  23359. /**
  23360. * Get the current class name of the texture useful for serialization or dynamic coding.
  23361. * @returns "Texture"
  23362. */
  23363. getClassName(): string;
  23364. /**
  23365. * Dispose the texture and release its associated resources.
  23366. */
  23367. dispose(): void;
  23368. /**
  23369. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23370. * @param parsedTexture Define the JSON representation of the texture
  23371. * @param scene Define the scene the parsed texture should be instantiated in
  23372. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23373. * @returns The parsed texture if successful
  23374. */
  23375. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23376. /**
  23377. * Creates a texture from its base 64 representation.
  23378. * @param data Define the base64 payload without the data: prefix
  23379. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23380. * @param scene Define the scene the texture should belong to
  23381. * @param noMipmap Forces the texture to not create mip map information if true
  23382. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23383. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23384. * @param onLoad define a callback triggered when the texture has been loaded
  23385. * @param onError define a callback triggered when an error occurred during the loading session
  23386. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23387. * @returns the created texture
  23388. */
  23389. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23390. /**
  23391. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23392. * @param data Define the base64 payload without the data: prefix
  23393. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23394. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23395. * @param scene Define the scene the texture should belong to
  23396. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23397. * @param noMipmap Forces the texture to not create mip map information if true
  23398. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23399. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23400. * @param onLoad define a callback triggered when the texture has been loaded
  23401. * @param onError define a callback triggered when an error occurred during the loading session
  23402. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23403. * @returns the created texture
  23404. */
  23405. 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;
  23406. }
  23407. }
  23408. declare module BABYLON {
  23409. /**
  23410. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23411. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23412. */
  23413. export class PostProcessManager {
  23414. private _scene;
  23415. private _indexBuffer;
  23416. private _vertexBuffers;
  23417. /**
  23418. * Creates a new instance PostProcess
  23419. * @param scene The scene that the post process is associated with.
  23420. */
  23421. constructor(scene: Scene);
  23422. private _prepareBuffers;
  23423. private _buildIndexBuffer;
  23424. /**
  23425. * Rebuilds the vertex buffers of the manager.
  23426. * @hidden
  23427. */
  23428. _rebuild(): void;
  23429. /**
  23430. * Prepares a frame to be run through a post process.
  23431. * @param sourceTexture The input texture to the post procesess. (default: null)
  23432. * @param postProcesses An array of post processes to be run. (default: null)
  23433. * @returns True if the post processes were able to be run.
  23434. * @hidden
  23435. */
  23436. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23437. /**
  23438. * Manually render a set of post processes to a texture.
  23439. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23440. * @param postProcesses An array of post processes to be run.
  23441. * @param targetTexture The target texture to render to.
  23442. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23443. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23444. * @param lodLevel defines which lod of the texture to render to
  23445. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23446. */
  23447. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23448. /**
  23449. * Finalize the result of the output of the postprocesses.
  23450. * @param doNotPresent If true the result will not be displayed to the screen.
  23451. * @param targetTexture The target texture to render to.
  23452. * @param faceIndex The index of the face to bind the target texture to.
  23453. * @param postProcesses The array of post processes to render.
  23454. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23455. * @hidden
  23456. */
  23457. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23458. /**
  23459. * Disposes of the post process manager.
  23460. */
  23461. dispose(): void;
  23462. }
  23463. }
  23464. declare module BABYLON {
  23465. /**
  23466. * This Helps creating a texture that will be created from a camera in your scene.
  23467. * It is basically a dynamic texture that could be used to create special effects for instance.
  23468. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23469. */
  23470. export class RenderTargetTexture extends Texture {
  23471. isCube: boolean;
  23472. /**
  23473. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23474. */
  23475. static readonly REFRESHRATE_RENDER_ONCE: number;
  23476. /**
  23477. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23478. */
  23479. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23480. /**
  23481. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23482. * the central point of your effect and can save a lot of performances.
  23483. */
  23484. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23485. /**
  23486. * Use this predicate to dynamically define the list of mesh you want to render.
  23487. * If set, the renderList property will be overwritten.
  23488. */
  23489. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23490. private _renderList;
  23491. /**
  23492. * Use this list to define the list of mesh you want to render.
  23493. */
  23494. get renderList(): Nullable<Array<AbstractMesh>>;
  23495. set renderList(value: Nullable<Array<AbstractMesh>>);
  23496. /**
  23497. * Use this function to overload the renderList array at rendering time.
  23498. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23499. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23500. * the cube (if the RTT is a cube, else layerOrFace=0).
  23501. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23502. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23503. * hold dummy elements!
  23504. */
  23505. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23506. private _hookArray;
  23507. /**
  23508. * Define if particles should be rendered in your texture.
  23509. */
  23510. renderParticles: boolean;
  23511. /**
  23512. * Define if sprites should be rendered in your texture.
  23513. */
  23514. renderSprites: boolean;
  23515. /**
  23516. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23517. */
  23518. coordinatesMode: number;
  23519. /**
  23520. * Define the camera used to render the texture.
  23521. */
  23522. activeCamera: Nullable<Camera>;
  23523. /**
  23524. * Override the mesh isReady function with your own one.
  23525. */
  23526. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23527. /**
  23528. * Override the render function of the texture with your own one.
  23529. */
  23530. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23531. /**
  23532. * Define if camera post processes should be use while rendering the texture.
  23533. */
  23534. useCameraPostProcesses: boolean;
  23535. /**
  23536. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23537. */
  23538. ignoreCameraViewport: boolean;
  23539. private _postProcessManager;
  23540. private _postProcesses;
  23541. private _resizeObserver;
  23542. /**
  23543. * An event triggered when the texture is unbind.
  23544. */
  23545. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23546. /**
  23547. * An event triggered when the texture is unbind.
  23548. */
  23549. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23550. private _onAfterUnbindObserver;
  23551. /**
  23552. * Set a after unbind callback in the texture.
  23553. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23554. */
  23555. set onAfterUnbind(callback: () => void);
  23556. /**
  23557. * An event triggered before rendering the texture
  23558. */
  23559. onBeforeRenderObservable: Observable<number>;
  23560. private _onBeforeRenderObserver;
  23561. /**
  23562. * Set a before render callback in the texture.
  23563. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23564. */
  23565. set onBeforeRender(callback: (faceIndex: number) => void);
  23566. /**
  23567. * An event triggered after rendering the texture
  23568. */
  23569. onAfterRenderObservable: Observable<number>;
  23570. private _onAfterRenderObserver;
  23571. /**
  23572. * Set a after render callback in the texture.
  23573. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23574. */
  23575. set onAfterRender(callback: (faceIndex: number) => void);
  23576. /**
  23577. * An event triggered after the texture clear
  23578. */
  23579. onClearObservable: Observable<Engine>;
  23580. private _onClearObserver;
  23581. /**
  23582. * Set a clear callback in the texture.
  23583. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23584. */
  23585. set onClear(callback: (Engine: Engine) => void);
  23586. /**
  23587. * An event triggered when the texture is resized.
  23588. */
  23589. onResizeObservable: Observable<RenderTargetTexture>;
  23590. /**
  23591. * Define the clear color of the Render Target if it should be different from the scene.
  23592. */
  23593. clearColor: Color4;
  23594. protected _size: number | {
  23595. width: number;
  23596. height: number;
  23597. layers?: number;
  23598. };
  23599. protected _initialSizeParameter: number | {
  23600. width: number;
  23601. height: number;
  23602. } | {
  23603. ratio: number;
  23604. };
  23605. protected _sizeRatio: Nullable<number>;
  23606. /** @hidden */
  23607. _generateMipMaps: boolean;
  23608. protected _renderingManager: RenderingManager;
  23609. /** @hidden */
  23610. _waitingRenderList: string[];
  23611. protected _doNotChangeAspectRatio: boolean;
  23612. protected _currentRefreshId: number;
  23613. protected _refreshRate: number;
  23614. protected _textureMatrix: Matrix;
  23615. protected _samples: number;
  23616. protected _renderTargetOptions: RenderTargetCreationOptions;
  23617. /**
  23618. * Gets render target creation options that were used.
  23619. */
  23620. get renderTargetOptions(): RenderTargetCreationOptions;
  23621. protected _onRatioRescale(): void;
  23622. /**
  23623. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23624. * It must define where the camera used to render the texture is set
  23625. */
  23626. boundingBoxPosition: Vector3;
  23627. private _boundingBoxSize;
  23628. /**
  23629. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23630. * When defined, the cubemap will switch to local mode
  23631. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23632. * @example https://www.babylonjs-playground.com/#RNASML
  23633. */
  23634. set boundingBoxSize(value: Vector3);
  23635. get boundingBoxSize(): Vector3;
  23636. /**
  23637. * In case the RTT has been created with a depth texture, get the associated
  23638. * depth texture.
  23639. * Otherwise, return null.
  23640. */
  23641. get depthStencilTexture(): Nullable<InternalTexture>;
  23642. /**
  23643. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23644. * or used a shadow, depth texture...
  23645. * @param name The friendly name of the texture
  23646. * @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)
  23647. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23648. * @param generateMipMaps True if mip maps need to be generated after render.
  23649. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23650. * @param type The type of the buffer in the RTT (int, half float, float...)
  23651. * @param isCube True if a cube texture needs to be created
  23652. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23653. * @param generateDepthBuffer True to generate a depth buffer
  23654. * @param generateStencilBuffer True to generate a stencil buffer
  23655. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23656. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23657. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23658. */
  23659. constructor(name: string, size: number | {
  23660. width: number;
  23661. height: number;
  23662. layers?: number;
  23663. } | {
  23664. ratio: number;
  23665. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23666. /**
  23667. * Creates a depth stencil texture.
  23668. * This is only available in WebGL 2 or with the depth texture extension available.
  23669. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23670. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23671. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23672. */
  23673. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23674. private _processSizeParameter;
  23675. /**
  23676. * Define the number of samples to use in case of MSAA.
  23677. * It defaults to one meaning no MSAA has been enabled.
  23678. */
  23679. get samples(): number;
  23680. set samples(value: number);
  23681. /**
  23682. * Resets the refresh counter of the texture and start bak from scratch.
  23683. * Could be useful to regenerate the texture if it is setup to render only once.
  23684. */
  23685. resetRefreshCounter(): void;
  23686. /**
  23687. * Define the refresh rate of the texture or the rendering frequency.
  23688. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23689. */
  23690. get refreshRate(): number;
  23691. set refreshRate(value: number);
  23692. /**
  23693. * Adds a post process to the render target rendering passes.
  23694. * @param postProcess define the post process to add
  23695. */
  23696. addPostProcess(postProcess: PostProcess): void;
  23697. /**
  23698. * Clear all the post processes attached to the render target
  23699. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23700. */
  23701. clearPostProcesses(dispose?: boolean): void;
  23702. /**
  23703. * Remove one of the post process from the list of attached post processes to the texture
  23704. * @param postProcess define the post process to remove from the list
  23705. */
  23706. removePostProcess(postProcess: PostProcess): void;
  23707. /** @hidden */
  23708. _shouldRender(): boolean;
  23709. /**
  23710. * Gets the actual render size of the texture.
  23711. * @returns the width of the render size
  23712. */
  23713. getRenderSize(): number;
  23714. /**
  23715. * Gets the actual render width of the texture.
  23716. * @returns the width of the render size
  23717. */
  23718. getRenderWidth(): number;
  23719. /**
  23720. * Gets the actual render height of the texture.
  23721. * @returns the height of the render size
  23722. */
  23723. getRenderHeight(): number;
  23724. /**
  23725. * Gets the actual number of layers of the texture.
  23726. * @returns the number of layers
  23727. */
  23728. getRenderLayers(): number;
  23729. /**
  23730. * Get if the texture can be rescaled or not.
  23731. */
  23732. get canRescale(): boolean;
  23733. /**
  23734. * Resize the texture using a ratio.
  23735. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23736. */
  23737. scale(ratio: number): void;
  23738. /**
  23739. * Get the texture reflection matrix used to rotate/transform the reflection.
  23740. * @returns the reflection matrix
  23741. */
  23742. getReflectionTextureMatrix(): Matrix;
  23743. /**
  23744. * Resize the texture to a new desired size.
  23745. * Be carrefull as it will recreate all the data in the new texture.
  23746. * @param size Define the new size. It can be:
  23747. * - a number for squared texture,
  23748. * - an object containing { width: number, height: number }
  23749. * - or an object containing a ratio { ratio: number }
  23750. */
  23751. resize(size: number | {
  23752. width: number;
  23753. height: number;
  23754. } | {
  23755. ratio: number;
  23756. }): void;
  23757. private _defaultRenderListPrepared;
  23758. /**
  23759. * Renders all the objects from the render list into the texture.
  23760. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23761. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23762. */
  23763. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23764. private _bestReflectionRenderTargetDimension;
  23765. private _prepareRenderingManager;
  23766. /**
  23767. * @hidden
  23768. * @param faceIndex face index to bind to if this is a cubetexture
  23769. * @param layer defines the index of the texture to bind in the array
  23770. */
  23771. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23772. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23773. private renderToTarget;
  23774. /**
  23775. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23776. * This allowed control for front to back rendering or reversly depending of the special needs.
  23777. *
  23778. * @param renderingGroupId The rendering group id corresponding to its index
  23779. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23780. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23781. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23782. */
  23783. 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;
  23784. /**
  23785. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23786. *
  23787. * @param renderingGroupId The rendering group id corresponding to its index
  23788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23789. */
  23790. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23791. /**
  23792. * Clones the texture.
  23793. * @returns the cloned texture
  23794. */
  23795. clone(): RenderTargetTexture;
  23796. /**
  23797. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23798. * @returns The JSON representation of the texture
  23799. */
  23800. serialize(): any;
  23801. /**
  23802. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23803. */
  23804. disposeFramebufferObjects(): void;
  23805. /**
  23806. * Dispose the texture and release its associated resources.
  23807. */
  23808. dispose(): void;
  23809. /** @hidden */
  23810. _rebuild(): void;
  23811. /**
  23812. * Clear the info related to rendering groups preventing retention point in material dispose.
  23813. */
  23814. freeRenderingGroups(): void;
  23815. /**
  23816. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23817. * @returns the view count
  23818. */
  23819. getViewCount(): number;
  23820. }
  23821. }
  23822. declare module BABYLON {
  23823. /**
  23824. * Class used to manipulate GUIDs
  23825. */
  23826. export class GUID {
  23827. /**
  23828. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23829. * Be aware Math.random() could cause collisions, but:
  23830. * "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"
  23831. * @returns a pseudo random id
  23832. */
  23833. static RandomId(): string;
  23834. }
  23835. }
  23836. declare module BABYLON {
  23837. /**
  23838. * Options to be used when creating a shadow depth material
  23839. */
  23840. export interface IIOptionShadowDepthMaterial {
  23841. /** Variables in the vertex shader code that need to have their names remapped.
  23842. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23843. * "var_name" should be either: worldPos or vNormalW
  23844. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23845. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23846. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23847. */
  23848. remappedVariables?: string[];
  23849. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23850. standalone?: boolean;
  23851. }
  23852. /**
  23853. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23854. */
  23855. export class ShadowDepthWrapper {
  23856. private _scene;
  23857. private _options?;
  23858. private _baseMaterial;
  23859. private _onEffectCreatedObserver;
  23860. private _subMeshToEffect;
  23861. private _subMeshToDepthEffect;
  23862. private _meshes;
  23863. /** @hidden */
  23864. _matriceNames: any;
  23865. /** Gets the standalone status of the wrapper */
  23866. get standalone(): boolean;
  23867. /** Gets the base material the wrapper is built upon */
  23868. get baseMaterial(): Material;
  23869. /**
  23870. * Instantiate a new shadow depth wrapper.
  23871. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23872. * generate the shadow depth map. For more information, please refer to the documentation:
  23873. * https://doc.babylonjs.com/babylon101/shadows
  23874. * @param baseMaterial Material to wrap
  23875. * @param scene Define the scene the material belongs to
  23876. * @param options Options used to create the wrapper
  23877. */
  23878. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23879. /**
  23880. * Gets the effect to use to generate the depth map
  23881. * @param subMesh subMesh to get the effect for
  23882. * @param shadowGenerator shadow generator to get the effect for
  23883. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23884. */
  23885. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23886. /**
  23887. * Specifies that the submesh is ready to be used for depth rendering
  23888. * @param subMesh submesh to check
  23889. * @param defines the list of defines to take into account when checking the effect
  23890. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23891. * @param useInstances specifies that instances should be used
  23892. * @returns a boolean indicating that the submesh is ready or not
  23893. */
  23894. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23895. /**
  23896. * Disposes the resources
  23897. */
  23898. dispose(): void;
  23899. private _makeEffect;
  23900. }
  23901. }
  23902. declare module BABYLON {
  23903. interface ThinEngine {
  23904. /**
  23905. * Unbind a list of render target textures from the webGL context
  23906. * This is used only when drawBuffer extension or webGL2 are active
  23907. * @param textures defines the render target textures to unbind
  23908. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23909. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23910. */
  23911. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23912. /**
  23913. * Create a multi render target texture
  23914. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23915. * @param size defines the size of the texture
  23916. * @param options defines the creation options
  23917. * @returns the cube texture as an InternalTexture
  23918. */
  23919. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23920. /**
  23921. * Update the sample count for a given multiple render target texture
  23922. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23923. * @param textures defines the textures to update
  23924. * @param samples defines the sample count to set
  23925. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23926. */
  23927. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23928. /**
  23929. * Select a subsets of attachments to draw to.
  23930. * @param attachments gl attachments
  23931. */
  23932. bindAttachments(attachments: number[]): void;
  23933. }
  23934. }
  23935. declare module BABYLON {
  23936. /**
  23937. * Creation options of the multi render target texture.
  23938. */
  23939. export interface IMultiRenderTargetOptions {
  23940. /**
  23941. * Define if the texture needs to create mip maps after render.
  23942. */
  23943. generateMipMaps?: boolean;
  23944. /**
  23945. * Define the types of all the draw buffers we want to create
  23946. */
  23947. types?: number[];
  23948. /**
  23949. * Define the sampling modes of all the draw buffers we want to create
  23950. */
  23951. samplingModes?: number[];
  23952. /**
  23953. * Define if a depth buffer is required
  23954. */
  23955. generateDepthBuffer?: boolean;
  23956. /**
  23957. * Define if a stencil buffer is required
  23958. */
  23959. generateStencilBuffer?: boolean;
  23960. /**
  23961. * Define if a depth texture is required instead of a depth buffer
  23962. */
  23963. generateDepthTexture?: boolean;
  23964. /**
  23965. * Define the number of desired draw buffers
  23966. */
  23967. textureCount?: number;
  23968. /**
  23969. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23970. */
  23971. doNotChangeAspectRatio?: boolean;
  23972. /**
  23973. * Define the default type of the buffers we are creating
  23974. */
  23975. defaultType?: number;
  23976. }
  23977. /**
  23978. * A multi render target, like a render target provides the ability to render to a texture.
  23979. * Unlike the render target, it can render to several draw buffers in one draw.
  23980. * This is specially interesting in deferred rendering or for any effects requiring more than
  23981. * just one color from a single pass.
  23982. */
  23983. export class MultiRenderTarget extends RenderTargetTexture {
  23984. private _internalTextures;
  23985. private _textures;
  23986. private _multiRenderTargetOptions;
  23987. private _count;
  23988. /**
  23989. * Get if draw buffers are currently supported by the used hardware and browser.
  23990. */
  23991. get isSupported(): boolean;
  23992. /**
  23993. * Get the list of textures generated by the multi render target.
  23994. */
  23995. get textures(): Texture[];
  23996. /**
  23997. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23998. */
  23999. get count(): number;
  24000. /**
  24001. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24002. */
  24003. get depthTexture(): Texture;
  24004. /**
  24005. * Set the wrapping mode on U of all the textures we are rendering to.
  24006. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24007. */
  24008. set wrapU(wrap: number);
  24009. /**
  24010. * Set the wrapping mode on V of all the textures we are rendering to.
  24011. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24012. */
  24013. set wrapV(wrap: number);
  24014. /**
  24015. * Instantiate a new multi render target texture.
  24016. * A multi render target, like a render target provides the ability to render to a texture.
  24017. * Unlike the render target, it can render to several draw buffers in one draw.
  24018. * This is specially interesting in deferred rendering or for any effects requiring more than
  24019. * just one color from a single pass.
  24020. * @param name Define the name of the texture
  24021. * @param size Define the size of the buffers to render to
  24022. * @param count Define the number of target we are rendering into
  24023. * @param scene Define the scene the texture belongs to
  24024. * @param options Define the options used to create the multi render target
  24025. */
  24026. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24027. /** @hidden */
  24028. _rebuild(): void;
  24029. private _createInternalTextures;
  24030. private _createTextures;
  24031. /**
  24032. * Define the number of samples used if MSAA is enabled.
  24033. */
  24034. get samples(): number;
  24035. set samples(value: number);
  24036. /**
  24037. * Resize all the textures in the multi render target.
  24038. * Be carrefull as it will recreate all the data in the new texture.
  24039. * @param size Define the new size
  24040. */
  24041. resize(size: any): void;
  24042. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24043. /**
  24044. * Dispose the render targets and their associated resources
  24045. */
  24046. dispose(): void;
  24047. /**
  24048. * Release all the underlying texture used as draw buffers.
  24049. */
  24050. releaseInternalTextures(): void;
  24051. }
  24052. }
  24053. declare module BABYLON {
  24054. /** @hidden */
  24055. export var imageProcessingPixelShader: {
  24056. name: string;
  24057. shader: string;
  24058. };
  24059. }
  24060. declare module BABYLON {
  24061. /**
  24062. * ImageProcessingPostProcess
  24063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24064. */
  24065. export class ImageProcessingPostProcess extends PostProcess {
  24066. /**
  24067. * Default configuration related to image processing available in the PBR Material.
  24068. */
  24069. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24070. /**
  24071. * Gets the image processing configuration used either in this material.
  24072. */
  24073. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24074. /**
  24075. * Sets the Default image processing configuration used either in the this material.
  24076. *
  24077. * If sets to null, the scene one is in use.
  24078. */
  24079. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24080. /**
  24081. * Keep track of the image processing observer to allow dispose and replace.
  24082. */
  24083. private _imageProcessingObserver;
  24084. /**
  24085. * Attaches a new image processing configuration to the PBR Material.
  24086. * @param configuration
  24087. */
  24088. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24089. /**
  24090. * If the post process is supported.
  24091. */
  24092. get isSupported(): boolean;
  24093. /**
  24094. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24095. */
  24096. get colorCurves(): Nullable<ColorCurves>;
  24097. /**
  24098. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24099. */
  24100. set colorCurves(value: Nullable<ColorCurves>);
  24101. /**
  24102. * Gets wether the color curves effect is enabled.
  24103. */
  24104. get colorCurvesEnabled(): boolean;
  24105. /**
  24106. * Sets wether the color curves effect is enabled.
  24107. */
  24108. set colorCurvesEnabled(value: boolean);
  24109. /**
  24110. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24111. */
  24112. get colorGradingTexture(): Nullable<BaseTexture>;
  24113. /**
  24114. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24115. */
  24116. set colorGradingTexture(value: Nullable<BaseTexture>);
  24117. /**
  24118. * Gets wether the color grading effect is enabled.
  24119. */
  24120. get colorGradingEnabled(): boolean;
  24121. /**
  24122. * Gets wether the color grading effect is enabled.
  24123. */
  24124. set colorGradingEnabled(value: boolean);
  24125. /**
  24126. * Gets exposure used in the effect.
  24127. */
  24128. get exposure(): number;
  24129. /**
  24130. * Sets exposure used in the effect.
  24131. */
  24132. set exposure(value: number);
  24133. /**
  24134. * Gets wether tonemapping is enabled or not.
  24135. */
  24136. get toneMappingEnabled(): boolean;
  24137. /**
  24138. * Sets wether tonemapping is enabled or not
  24139. */
  24140. set toneMappingEnabled(value: boolean);
  24141. /**
  24142. * Gets the type of tone mapping effect.
  24143. */
  24144. get toneMappingType(): number;
  24145. /**
  24146. * Sets the type of tone mapping effect.
  24147. */
  24148. set toneMappingType(value: number);
  24149. /**
  24150. * Gets contrast used in the effect.
  24151. */
  24152. get contrast(): number;
  24153. /**
  24154. * Sets contrast used in the effect.
  24155. */
  24156. set contrast(value: number);
  24157. /**
  24158. * Gets Vignette stretch size.
  24159. */
  24160. get vignetteStretch(): number;
  24161. /**
  24162. * Sets Vignette stretch size.
  24163. */
  24164. set vignetteStretch(value: number);
  24165. /**
  24166. * Gets Vignette centre X Offset.
  24167. */
  24168. get vignetteCentreX(): number;
  24169. /**
  24170. * Sets Vignette centre X Offset.
  24171. */
  24172. set vignetteCentreX(value: number);
  24173. /**
  24174. * Gets Vignette centre Y Offset.
  24175. */
  24176. get vignetteCentreY(): number;
  24177. /**
  24178. * Sets Vignette centre Y Offset.
  24179. */
  24180. set vignetteCentreY(value: number);
  24181. /**
  24182. * Gets Vignette weight or intensity of the vignette effect.
  24183. */
  24184. get vignetteWeight(): number;
  24185. /**
  24186. * Sets Vignette weight or intensity of the vignette effect.
  24187. */
  24188. set vignetteWeight(value: number);
  24189. /**
  24190. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24191. * if vignetteEnabled is set to true.
  24192. */
  24193. get vignetteColor(): Color4;
  24194. /**
  24195. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24196. * if vignetteEnabled is set to true.
  24197. */
  24198. set vignetteColor(value: Color4);
  24199. /**
  24200. * Gets Camera field of view used by the Vignette effect.
  24201. */
  24202. get vignetteCameraFov(): number;
  24203. /**
  24204. * Sets Camera field of view used by the Vignette effect.
  24205. */
  24206. set vignetteCameraFov(value: number);
  24207. /**
  24208. * Gets the vignette blend mode allowing different kind of effect.
  24209. */
  24210. get vignetteBlendMode(): number;
  24211. /**
  24212. * Sets the vignette blend mode allowing different kind of effect.
  24213. */
  24214. set vignetteBlendMode(value: number);
  24215. /**
  24216. * Gets wether the vignette effect is enabled.
  24217. */
  24218. get vignetteEnabled(): boolean;
  24219. /**
  24220. * Sets wether the vignette effect is enabled.
  24221. */
  24222. set vignetteEnabled(value: boolean);
  24223. private _fromLinearSpace;
  24224. /**
  24225. * Gets wether the input of the processing is in Gamma or Linear Space.
  24226. */
  24227. get fromLinearSpace(): boolean;
  24228. /**
  24229. * Sets wether the input of the processing is in Gamma or Linear Space.
  24230. */
  24231. set fromLinearSpace(value: boolean);
  24232. /**
  24233. * Defines cache preventing GC.
  24234. */
  24235. private _defines;
  24236. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24237. /**
  24238. * "ImageProcessingPostProcess"
  24239. * @returns "ImageProcessingPostProcess"
  24240. */
  24241. getClassName(): string;
  24242. /**
  24243. * @hidden
  24244. */
  24245. _updateParameters(): void;
  24246. dispose(camera?: Camera): void;
  24247. }
  24248. }
  24249. declare module BABYLON {
  24250. /** @hidden */
  24251. export var fibonacci: {
  24252. name: string;
  24253. shader: string;
  24254. };
  24255. }
  24256. declare module BABYLON {
  24257. /** @hidden */
  24258. export var subSurfaceScatteringFunctions: {
  24259. name: string;
  24260. shader: string;
  24261. };
  24262. }
  24263. declare module BABYLON {
  24264. /** @hidden */
  24265. export var diffusionProfile: {
  24266. name: string;
  24267. shader: string;
  24268. };
  24269. }
  24270. declare module BABYLON {
  24271. /** @hidden */
  24272. export var subSurfaceScatteringPixelShader: {
  24273. name: string;
  24274. shader: string;
  24275. };
  24276. }
  24277. declare module BABYLON {
  24278. /**
  24279. * Sub surface scattering post process
  24280. */
  24281. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24282. /**
  24283. * Gets a string identifying the name of the class
  24284. * @returns "SubSurfaceScatteringPostProcess" string
  24285. */
  24286. getClassName(): string;
  24287. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24288. }
  24289. }
  24290. declare module BABYLON {
  24291. /**
  24292. * Interface for defining prepass effects in the prepass post-process pipeline
  24293. */
  24294. export interface PrePassEffectConfiguration {
  24295. /**
  24296. * Post process to attach for this effect
  24297. */
  24298. postProcess: PostProcess;
  24299. /**
  24300. * Is the effect enabled
  24301. */
  24302. enabled: boolean;
  24303. /**
  24304. * Disposes the effect configuration
  24305. */
  24306. dispose(): void;
  24307. /**
  24308. * Disposes the effect configuration
  24309. */
  24310. createPostProcess: () => PostProcess;
  24311. }
  24312. }
  24313. declare module BABYLON {
  24314. /**
  24315. * Contains all parameters needed for the prepass to perform
  24316. * screen space subsurface scattering
  24317. */
  24318. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24319. private _ssDiffusionS;
  24320. private _ssFilterRadii;
  24321. private _ssDiffusionD;
  24322. /**
  24323. * Post process to attach for screen space subsurface scattering
  24324. */
  24325. postProcess: SubSurfaceScatteringPostProcess;
  24326. /**
  24327. * Diffusion profile color for subsurface scattering
  24328. */
  24329. get ssDiffusionS(): number[];
  24330. /**
  24331. * Diffusion profile max color channel value for subsurface scattering
  24332. */
  24333. get ssDiffusionD(): number[];
  24334. /**
  24335. * Diffusion profile filter radius for subsurface scattering
  24336. */
  24337. get ssFilterRadii(): number[];
  24338. /**
  24339. * Is subsurface enabled
  24340. */
  24341. enabled: boolean;
  24342. /**
  24343. * Diffusion profile colors for subsurface scattering
  24344. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24345. * See ...
  24346. * Note that you can only store up to 5 of them
  24347. */
  24348. ssDiffusionProfileColors: Color3[];
  24349. /**
  24350. * Defines the ratio real world => scene units.
  24351. * Used for subsurface scattering
  24352. */
  24353. metersPerUnit: number;
  24354. private _scene;
  24355. /**
  24356. * Builds a subsurface configuration object
  24357. * @param scene The scene
  24358. */
  24359. constructor(scene: Scene);
  24360. /**
  24361. * Adds a new diffusion profile.
  24362. * Useful for more realistic subsurface scattering on diverse materials.
  24363. * @param color The color of the diffusion profile. Should be the average color of the material.
  24364. * @return The index of the diffusion profile for the material subsurface configuration
  24365. */
  24366. addDiffusionProfile(color: Color3): number;
  24367. /**
  24368. * Creates the sss post process
  24369. * @return The created post process
  24370. */
  24371. createPostProcess(): SubSurfaceScatteringPostProcess;
  24372. /**
  24373. * Deletes all diffusion profiles.
  24374. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24375. */
  24376. clearAllDiffusionProfiles(): void;
  24377. /**
  24378. * Disposes this object
  24379. */
  24380. dispose(): void;
  24381. /**
  24382. * @hidden
  24383. * https://zero-radiance.github.io/post/sampling-diffusion/
  24384. *
  24385. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24386. * ------------------------------------------------------------------------------------
  24387. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24388. * PDF[r, phi, s] = r * R[r, phi, s]
  24389. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24390. * ------------------------------------------------------------------------------------
  24391. * We importance sample the color channel with the widest scattering distance.
  24392. */
  24393. getDiffusionProfileParameters(color: Color3): number;
  24394. /**
  24395. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24396. * 'u' is the random number (the value of the CDF): [0, 1).
  24397. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24398. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24399. */
  24400. private _sampleBurleyDiffusionProfile;
  24401. }
  24402. }
  24403. declare module BABYLON {
  24404. /**
  24405. * Renders a pre pass of the scene
  24406. * This means every mesh in the scene will be rendered to a render target texture
  24407. * And then this texture will be composited to the rendering canvas with post processes
  24408. * It is necessary for effects like subsurface scattering or deferred shading
  24409. */
  24410. export class PrePassRenderer {
  24411. /** @hidden */
  24412. static _SceneComponentInitialization: (scene: Scene) => void;
  24413. private _scene;
  24414. private _engine;
  24415. private _isDirty;
  24416. /**
  24417. * Number of textures in the multi render target texture where the scene is directly rendered
  24418. */
  24419. readonly mrtCount: number;
  24420. /**
  24421. * The render target where the scene is directly rendered
  24422. */
  24423. prePassRT: MultiRenderTarget;
  24424. private _mrtTypes;
  24425. private _multiRenderAttachments;
  24426. private _defaultAttachments;
  24427. private _clearAttachments;
  24428. private _postProcesses;
  24429. private readonly _clearColor;
  24430. /**
  24431. * Image processing post process for composition
  24432. */
  24433. imageProcessingPostProcess: ImageProcessingPostProcess;
  24434. /**
  24435. * Configuration for sub surface scattering post process
  24436. */
  24437. subSurfaceConfiguration: SubSurfaceConfiguration;
  24438. /**
  24439. * Should materials render their geometry on the MRT
  24440. */
  24441. materialsShouldRenderGeometry: boolean;
  24442. /**
  24443. * Should materials render the irradiance information on the MRT
  24444. */
  24445. materialsShouldRenderIrradiance: boolean;
  24446. private _enabled;
  24447. /**
  24448. * Indicates if the prepass is enabled
  24449. */
  24450. get enabled(): boolean;
  24451. /**
  24452. * How many samples are used for MSAA of the scene render target
  24453. */
  24454. get samples(): number;
  24455. set samples(n: number);
  24456. /**
  24457. * Instanciates a prepass renderer
  24458. * @param scene The scene
  24459. */
  24460. constructor(scene: Scene);
  24461. private _initializeAttachments;
  24462. private _createCompositionEffect;
  24463. /**
  24464. * Indicates if rendering a prepass is supported
  24465. */
  24466. get isSupported(): boolean;
  24467. /**
  24468. * Sets the proper output textures to draw in the engine.
  24469. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24470. */
  24471. bindAttachmentsForEffect(effect: Effect): void;
  24472. /**
  24473. * @hidden
  24474. */
  24475. _beforeCameraDraw(): void;
  24476. /**
  24477. * @hidden
  24478. */
  24479. _afterCameraDraw(): void;
  24480. private _checkRTSize;
  24481. private _bindFrameBuffer;
  24482. /**
  24483. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24484. */
  24485. clear(): void;
  24486. private _setState;
  24487. private _enable;
  24488. private _disable;
  24489. private _resetPostProcessChain;
  24490. private _bindPostProcessChain;
  24491. /**
  24492. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24493. */
  24494. markAsDirty(): void;
  24495. private _update;
  24496. /**
  24497. * Disposes the prepass renderer.
  24498. */
  24499. dispose(): void;
  24500. }
  24501. }
  24502. declare module BABYLON {
  24503. /**
  24504. * Options for compiling materials.
  24505. */
  24506. export interface IMaterialCompilationOptions {
  24507. /**
  24508. * Defines whether clip planes are enabled.
  24509. */
  24510. clipPlane: boolean;
  24511. /**
  24512. * Defines whether instances are enabled.
  24513. */
  24514. useInstances: boolean;
  24515. }
  24516. /**
  24517. * Options passed when calling customShaderNameResolve
  24518. */
  24519. export interface ICustomShaderNameResolveOptions {
  24520. /**
  24521. * 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
  24522. */
  24523. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24524. }
  24525. /**
  24526. * Base class for the main features of a material in Babylon.js
  24527. */
  24528. export class Material implements IAnimatable {
  24529. /**
  24530. * Returns the triangle fill mode
  24531. */
  24532. static readonly TriangleFillMode: number;
  24533. /**
  24534. * Returns the wireframe mode
  24535. */
  24536. static readonly WireFrameFillMode: number;
  24537. /**
  24538. * Returns the point fill mode
  24539. */
  24540. static readonly PointFillMode: number;
  24541. /**
  24542. * Returns the point list draw mode
  24543. */
  24544. static readonly PointListDrawMode: number;
  24545. /**
  24546. * Returns the line list draw mode
  24547. */
  24548. static readonly LineListDrawMode: number;
  24549. /**
  24550. * Returns the line loop draw mode
  24551. */
  24552. static readonly LineLoopDrawMode: number;
  24553. /**
  24554. * Returns the line strip draw mode
  24555. */
  24556. static readonly LineStripDrawMode: number;
  24557. /**
  24558. * Returns the triangle strip draw mode
  24559. */
  24560. static readonly TriangleStripDrawMode: number;
  24561. /**
  24562. * Returns the triangle fan draw mode
  24563. */
  24564. static readonly TriangleFanDrawMode: number;
  24565. /**
  24566. * Stores the clock-wise side orientation
  24567. */
  24568. static readonly ClockWiseSideOrientation: number;
  24569. /**
  24570. * Stores the counter clock-wise side orientation
  24571. */
  24572. static readonly CounterClockWiseSideOrientation: number;
  24573. /**
  24574. * The dirty texture flag value
  24575. */
  24576. static readonly TextureDirtyFlag: number;
  24577. /**
  24578. * The dirty light flag value
  24579. */
  24580. static readonly LightDirtyFlag: number;
  24581. /**
  24582. * The dirty fresnel flag value
  24583. */
  24584. static readonly FresnelDirtyFlag: number;
  24585. /**
  24586. * The dirty attribute flag value
  24587. */
  24588. static readonly AttributesDirtyFlag: number;
  24589. /**
  24590. * The dirty misc flag value
  24591. */
  24592. static readonly MiscDirtyFlag: number;
  24593. /**
  24594. * The all dirty flag value
  24595. */
  24596. static readonly AllDirtyFlag: number;
  24597. /**
  24598. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24599. */
  24600. static readonly MATERIAL_OPAQUE: number;
  24601. /**
  24602. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24603. */
  24604. static readonly MATERIAL_ALPHATEST: number;
  24605. /**
  24606. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24607. */
  24608. static readonly MATERIAL_ALPHABLEND: number;
  24609. /**
  24610. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24611. * They are also discarded below the alpha cutoff threshold to improve performances.
  24612. */
  24613. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24614. /**
  24615. * The Whiteout method is used to blend normals.
  24616. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24617. */
  24618. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24619. /**
  24620. * The Reoriented Normal Mapping method is used to blend normals.
  24621. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24622. */
  24623. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24624. /**
  24625. * Custom callback helping to override the default shader used in the material.
  24626. */
  24627. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24628. /**
  24629. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24630. */
  24631. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24632. /**
  24633. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24634. * This means that the material can keep using a previous shader while a new one is being compiled.
  24635. * This is mostly used when shader parallel compilation is supported (true by default)
  24636. */
  24637. allowShaderHotSwapping: boolean;
  24638. /**
  24639. * The ID of the material
  24640. */
  24641. id: string;
  24642. /**
  24643. * Gets or sets the unique id of the material
  24644. */
  24645. uniqueId: number;
  24646. /**
  24647. * The name of the material
  24648. */
  24649. name: string;
  24650. /**
  24651. * Gets or sets user defined metadata
  24652. */
  24653. metadata: any;
  24654. /**
  24655. * For internal use only. Please do not use.
  24656. */
  24657. reservedDataStore: any;
  24658. /**
  24659. * Specifies if the ready state should be checked on each call
  24660. */
  24661. checkReadyOnEveryCall: boolean;
  24662. /**
  24663. * Specifies if the ready state should be checked once
  24664. */
  24665. checkReadyOnlyOnce: boolean;
  24666. /**
  24667. * The state of the material
  24668. */
  24669. state: string;
  24670. /**
  24671. * If the material can be rendered to several textures with MRT extension
  24672. */
  24673. get canRenderToMRT(): boolean;
  24674. /**
  24675. * The alpha value of the material
  24676. */
  24677. protected _alpha: number;
  24678. /**
  24679. * List of inspectable custom properties (used by the Inspector)
  24680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24681. */
  24682. inspectableCustomProperties: IInspectable[];
  24683. /**
  24684. * Sets the alpha value of the material
  24685. */
  24686. set alpha(value: number);
  24687. /**
  24688. * Gets the alpha value of the material
  24689. */
  24690. get alpha(): number;
  24691. /**
  24692. * Specifies if back face culling is enabled
  24693. */
  24694. protected _backFaceCulling: boolean;
  24695. /**
  24696. * Sets the back-face culling state
  24697. */
  24698. set backFaceCulling(value: boolean);
  24699. /**
  24700. * Gets the back-face culling state
  24701. */
  24702. get backFaceCulling(): boolean;
  24703. /**
  24704. * Stores the value for side orientation
  24705. */
  24706. sideOrientation: number;
  24707. /**
  24708. * Callback triggered when the material is compiled
  24709. */
  24710. onCompiled: Nullable<(effect: Effect) => void>;
  24711. /**
  24712. * Callback triggered when an error occurs
  24713. */
  24714. onError: Nullable<(effect: Effect, errors: string) => void>;
  24715. /**
  24716. * Callback triggered to get the render target textures
  24717. */
  24718. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24719. /**
  24720. * Gets a boolean indicating that current material needs to register RTT
  24721. */
  24722. get hasRenderTargetTextures(): boolean;
  24723. /**
  24724. * Specifies if the material should be serialized
  24725. */
  24726. doNotSerialize: boolean;
  24727. /**
  24728. * @hidden
  24729. */
  24730. _storeEffectOnSubMeshes: boolean;
  24731. /**
  24732. * Stores the animations for the material
  24733. */
  24734. animations: Nullable<Array<Animation>>;
  24735. /**
  24736. * An event triggered when the material is disposed
  24737. */
  24738. onDisposeObservable: Observable<Material>;
  24739. /**
  24740. * An observer which watches for dispose events
  24741. */
  24742. private _onDisposeObserver;
  24743. private _onUnBindObservable;
  24744. /**
  24745. * Called during a dispose event
  24746. */
  24747. set onDispose(callback: () => void);
  24748. private _onBindObservable;
  24749. /**
  24750. * An event triggered when the material is bound
  24751. */
  24752. get onBindObservable(): Observable<AbstractMesh>;
  24753. /**
  24754. * An observer which watches for bind events
  24755. */
  24756. private _onBindObserver;
  24757. /**
  24758. * Called during a bind event
  24759. */
  24760. set onBind(callback: (Mesh: AbstractMesh) => void);
  24761. /**
  24762. * An event triggered when the material is unbound
  24763. */
  24764. get onUnBindObservable(): Observable<Material>;
  24765. protected _onEffectCreatedObservable: Nullable<Observable<{
  24766. effect: Effect;
  24767. subMesh: Nullable<SubMesh>;
  24768. }>>;
  24769. /**
  24770. * An event triggered when the effect is (re)created
  24771. */
  24772. get onEffectCreatedObservable(): Observable<{
  24773. effect: Effect;
  24774. subMesh: Nullable<SubMesh>;
  24775. }>;
  24776. /**
  24777. * Stores the value of the alpha mode
  24778. */
  24779. private _alphaMode;
  24780. /**
  24781. * Sets the value of the alpha mode.
  24782. *
  24783. * | Value | Type | Description |
  24784. * | --- | --- | --- |
  24785. * | 0 | ALPHA_DISABLE | |
  24786. * | 1 | ALPHA_ADD | |
  24787. * | 2 | ALPHA_COMBINE | |
  24788. * | 3 | ALPHA_SUBTRACT | |
  24789. * | 4 | ALPHA_MULTIPLY | |
  24790. * | 5 | ALPHA_MAXIMIZED | |
  24791. * | 6 | ALPHA_ONEONE | |
  24792. * | 7 | ALPHA_PREMULTIPLIED | |
  24793. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24794. * | 9 | ALPHA_INTERPOLATE | |
  24795. * | 10 | ALPHA_SCREENMODE | |
  24796. *
  24797. */
  24798. set alphaMode(value: number);
  24799. /**
  24800. * Gets the value of the alpha mode
  24801. */
  24802. get alphaMode(): number;
  24803. /**
  24804. * Stores the state of the need depth pre-pass value
  24805. */
  24806. private _needDepthPrePass;
  24807. /**
  24808. * Sets the need depth pre-pass value
  24809. */
  24810. set needDepthPrePass(value: boolean);
  24811. /**
  24812. * Gets the depth pre-pass value
  24813. */
  24814. get needDepthPrePass(): boolean;
  24815. /**
  24816. * Specifies if depth writing should be disabled
  24817. */
  24818. disableDepthWrite: boolean;
  24819. /**
  24820. * Specifies if color writing should be disabled
  24821. */
  24822. disableColorWrite: boolean;
  24823. /**
  24824. * Specifies if depth writing should be forced
  24825. */
  24826. forceDepthWrite: boolean;
  24827. /**
  24828. * Specifies the depth function that should be used. 0 means the default engine function
  24829. */
  24830. depthFunction: number;
  24831. /**
  24832. * Specifies if there should be a separate pass for culling
  24833. */
  24834. separateCullingPass: boolean;
  24835. /**
  24836. * Stores the state specifing if fog should be enabled
  24837. */
  24838. private _fogEnabled;
  24839. /**
  24840. * Sets the state for enabling fog
  24841. */
  24842. set fogEnabled(value: boolean);
  24843. /**
  24844. * Gets the value of the fog enabled state
  24845. */
  24846. get fogEnabled(): boolean;
  24847. /**
  24848. * Stores the size of points
  24849. */
  24850. pointSize: number;
  24851. /**
  24852. * Stores the z offset value
  24853. */
  24854. zOffset: number;
  24855. get wireframe(): boolean;
  24856. /**
  24857. * Sets the state of wireframe mode
  24858. */
  24859. set wireframe(value: boolean);
  24860. /**
  24861. * Gets the value specifying if point clouds are enabled
  24862. */
  24863. get pointsCloud(): boolean;
  24864. /**
  24865. * Sets the state of point cloud mode
  24866. */
  24867. set pointsCloud(value: boolean);
  24868. /**
  24869. * Gets the material fill mode
  24870. */
  24871. get fillMode(): number;
  24872. /**
  24873. * Sets the material fill mode
  24874. */
  24875. set fillMode(value: number);
  24876. /**
  24877. * @hidden
  24878. * Stores the effects for the material
  24879. */
  24880. _effect: Nullable<Effect>;
  24881. /**
  24882. * Specifies if uniform buffers should be used
  24883. */
  24884. private _useUBO;
  24885. /**
  24886. * Stores a reference to the scene
  24887. */
  24888. private _scene;
  24889. /**
  24890. * Stores the fill mode state
  24891. */
  24892. private _fillMode;
  24893. /**
  24894. * Specifies if the depth write state should be cached
  24895. */
  24896. private _cachedDepthWriteState;
  24897. /**
  24898. * Specifies if the color write state should be cached
  24899. */
  24900. private _cachedColorWriteState;
  24901. /**
  24902. * Specifies if the depth function state should be cached
  24903. */
  24904. private _cachedDepthFunctionState;
  24905. /**
  24906. * Stores the uniform buffer
  24907. */
  24908. protected _uniformBuffer: UniformBuffer;
  24909. /** @hidden */
  24910. _indexInSceneMaterialArray: number;
  24911. /** @hidden */
  24912. meshMap: Nullable<{
  24913. [id: string]: AbstractMesh | undefined;
  24914. }>;
  24915. /**
  24916. * Creates a material instance
  24917. * @param name defines the name of the material
  24918. * @param scene defines the scene to reference
  24919. * @param doNotAdd specifies if the material should be added to the scene
  24920. */
  24921. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24922. /**
  24923. * Returns a string representation of the current material
  24924. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24925. * @returns a string with material information
  24926. */
  24927. toString(fullDetails?: boolean): string;
  24928. /**
  24929. * Gets the class name of the material
  24930. * @returns a string with the class name of the material
  24931. */
  24932. getClassName(): string;
  24933. /**
  24934. * Specifies if updates for the material been locked
  24935. */
  24936. get isFrozen(): boolean;
  24937. /**
  24938. * Locks updates for the material
  24939. */
  24940. freeze(): void;
  24941. /**
  24942. * Unlocks updates for the material
  24943. */
  24944. unfreeze(): void;
  24945. /**
  24946. * Specifies if the material is ready to be used
  24947. * @param mesh defines the mesh to check
  24948. * @param useInstances specifies if instances should be used
  24949. * @returns a boolean indicating if the material is ready to be used
  24950. */
  24951. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24952. /**
  24953. * Specifies that the submesh is ready to be used
  24954. * @param mesh defines the mesh to check
  24955. * @param subMesh defines which submesh to check
  24956. * @param useInstances specifies that instances should be used
  24957. * @returns a boolean indicating that the submesh is ready or not
  24958. */
  24959. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24960. /**
  24961. * Returns the material effect
  24962. * @returns the effect associated with the material
  24963. */
  24964. getEffect(): Nullable<Effect>;
  24965. /**
  24966. * Returns the current scene
  24967. * @returns a Scene
  24968. */
  24969. getScene(): Scene;
  24970. /**
  24971. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24972. */
  24973. protected _forceAlphaTest: boolean;
  24974. /**
  24975. * The transparency mode of the material.
  24976. */
  24977. protected _transparencyMode: Nullable<number>;
  24978. /**
  24979. * Gets the current transparency mode.
  24980. */
  24981. get transparencyMode(): Nullable<number>;
  24982. /**
  24983. * Sets the transparency mode of the material.
  24984. *
  24985. * | Value | Type | Description |
  24986. * | ----- | ----------------------------------- | ----------- |
  24987. * | 0 | OPAQUE | |
  24988. * | 1 | ALPHATEST | |
  24989. * | 2 | ALPHABLEND | |
  24990. * | 3 | ALPHATESTANDBLEND | |
  24991. *
  24992. */
  24993. set transparencyMode(value: Nullable<number>);
  24994. /**
  24995. * Returns true if alpha blending should be disabled.
  24996. */
  24997. protected get _disableAlphaBlending(): boolean;
  24998. /**
  24999. * Specifies whether or not this material should be rendered in alpha blend mode.
  25000. * @returns a boolean specifying if alpha blending is needed
  25001. */
  25002. needAlphaBlending(): boolean;
  25003. /**
  25004. * Specifies if the mesh will require alpha blending
  25005. * @param mesh defines the mesh to check
  25006. * @returns a boolean specifying if alpha blending is needed for the mesh
  25007. */
  25008. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25009. /**
  25010. * Specifies whether or not this material should be rendered in alpha test mode.
  25011. * @returns a boolean specifying if an alpha test is needed.
  25012. */
  25013. needAlphaTesting(): boolean;
  25014. /**
  25015. * Specifies if material alpha testing should be turned on for the mesh
  25016. * @param mesh defines the mesh to check
  25017. */
  25018. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25019. /**
  25020. * Gets the texture used for the alpha test
  25021. * @returns the texture to use for alpha testing
  25022. */
  25023. getAlphaTestTexture(): Nullable<BaseTexture>;
  25024. /**
  25025. * Marks the material to indicate that it needs to be re-calculated
  25026. */
  25027. markDirty(): void;
  25028. /** @hidden */
  25029. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25030. /**
  25031. * Binds the material to the mesh
  25032. * @param world defines the world transformation matrix
  25033. * @param mesh defines the mesh to bind the material to
  25034. */
  25035. bind(world: Matrix, mesh?: Mesh): void;
  25036. /**
  25037. * Binds the submesh to the material
  25038. * @param world defines the world transformation matrix
  25039. * @param mesh defines the mesh containing the submesh
  25040. * @param subMesh defines the submesh to bind the material to
  25041. */
  25042. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25043. /**
  25044. * Binds the world matrix to the material
  25045. * @param world defines the world transformation matrix
  25046. */
  25047. bindOnlyWorldMatrix(world: Matrix): void;
  25048. /**
  25049. * Binds the scene's uniform buffer to the effect.
  25050. * @param effect defines the effect to bind to the scene uniform buffer
  25051. * @param sceneUbo defines the uniform buffer storing scene data
  25052. */
  25053. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25054. /**
  25055. * Binds the view matrix to the effect
  25056. * @param effect defines the effect to bind the view matrix to
  25057. */
  25058. bindView(effect: Effect): void;
  25059. /**
  25060. * Binds the view projection matrix to the effect
  25061. * @param effect defines the effect to bind the view projection matrix to
  25062. */
  25063. bindViewProjection(effect: Effect): void;
  25064. /**
  25065. * Processes to execute after binding the material to a mesh
  25066. * @param mesh defines the rendered mesh
  25067. */
  25068. protected _afterBind(mesh?: Mesh): void;
  25069. /**
  25070. * Unbinds the material from the mesh
  25071. */
  25072. unbind(): void;
  25073. /**
  25074. * Gets the active textures from the material
  25075. * @returns an array of textures
  25076. */
  25077. getActiveTextures(): BaseTexture[];
  25078. /**
  25079. * Specifies if the material uses a texture
  25080. * @param texture defines the texture to check against the material
  25081. * @returns a boolean specifying if the material uses the texture
  25082. */
  25083. hasTexture(texture: BaseTexture): boolean;
  25084. /**
  25085. * Makes a duplicate of the material, and gives it a new name
  25086. * @param name defines the new name for the duplicated material
  25087. * @returns the cloned material
  25088. */
  25089. clone(name: string): Nullable<Material>;
  25090. /**
  25091. * Gets the meshes bound to the material
  25092. * @returns an array of meshes bound to the material
  25093. */
  25094. getBindedMeshes(): AbstractMesh[];
  25095. /**
  25096. * Force shader compilation
  25097. * @param mesh defines the mesh associated with this material
  25098. * @param onCompiled defines a function to execute once the material is compiled
  25099. * @param options defines the options to configure the compilation
  25100. * @param onError defines a function to execute if the material fails compiling
  25101. */
  25102. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25103. /**
  25104. * Force shader compilation
  25105. * @param mesh defines the mesh that will use this material
  25106. * @param options defines additional options for compiling the shaders
  25107. * @returns a promise that resolves when the compilation completes
  25108. */
  25109. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25110. private static readonly _AllDirtyCallBack;
  25111. private static readonly _ImageProcessingDirtyCallBack;
  25112. private static readonly _TextureDirtyCallBack;
  25113. private static readonly _FresnelDirtyCallBack;
  25114. private static readonly _MiscDirtyCallBack;
  25115. private static readonly _LightsDirtyCallBack;
  25116. private static readonly _AttributeDirtyCallBack;
  25117. private static _FresnelAndMiscDirtyCallBack;
  25118. private static _TextureAndMiscDirtyCallBack;
  25119. private static readonly _DirtyCallbackArray;
  25120. private static readonly _RunDirtyCallBacks;
  25121. /**
  25122. * Marks a define in the material to indicate that it needs to be re-computed
  25123. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25124. */
  25125. markAsDirty(flag: number): void;
  25126. /**
  25127. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25128. * @param func defines a function which checks material defines against the submeshes
  25129. */
  25130. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25131. /**
  25132. * Indicates that the scene should check if the rendering now needs a prepass
  25133. */
  25134. protected _markScenePrePassDirty(): void;
  25135. /**
  25136. * Indicates that we need to re-calculated for all submeshes
  25137. */
  25138. protected _markAllSubMeshesAsAllDirty(): void;
  25139. /**
  25140. * Indicates that image processing needs to be re-calculated for all submeshes
  25141. */
  25142. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25143. /**
  25144. * Indicates that textures need to be re-calculated for all submeshes
  25145. */
  25146. protected _markAllSubMeshesAsTexturesDirty(): void;
  25147. /**
  25148. * Indicates that fresnel needs to be re-calculated for all submeshes
  25149. */
  25150. protected _markAllSubMeshesAsFresnelDirty(): void;
  25151. /**
  25152. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25153. */
  25154. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25155. /**
  25156. * Indicates that lights need to be re-calculated for all submeshes
  25157. */
  25158. protected _markAllSubMeshesAsLightsDirty(): void;
  25159. /**
  25160. * Indicates that attributes need to be re-calculated for all submeshes
  25161. */
  25162. protected _markAllSubMeshesAsAttributesDirty(): void;
  25163. /**
  25164. * Indicates that misc needs to be re-calculated for all submeshes
  25165. */
  25166. protected _markAllSubMeshesAsMiscDirty(): void;
  25167. /**
  25168. * Indicates that textures and misc need to be re-calculated for all submeshes
  25169. */
  25170. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25171. /**
  25172. * Sets the required values to the prepass renderer.
  25173. * @param prePassRenderer defines the prepass renderer to setup.
  25174. * @returns true if the pre pass is needed.
  25175. */
  25176. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25177. /**
  25178. * Disposes the material
  25179. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25180. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25181. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25182. */
  25183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25184. /** @hidden */
  25185. private releaseVertexArrayObject;
  25186. /**
  25187. * Serializes this material
  25188. * @returns the serialized material object
  25189. */
  25190. serialize(): any;
  25191. /**
  25192. * Creates a material from parsed material data
  25193. * @param parsedMaterial defines parsed material data
  25194. * @param scene defines the hosting scene
  25195. * @param rootUrl defines the root URL to use to load textures
  25196. * @returns a new material
  25197. */
  25198. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25199. }
  25200. }
  25201. declare module BABYLON {
  25202. /**
  25203. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25204. * separate meshes. This can be use to improve performances.
  25205. * @see https://doc.babylonjs.com/how_to/multi_materials
  25206. */
  25207. export class MultiMaterial extends Material {
  25208. private _subMaterials;
  25209. /**
  25210. * Gets or Sets the list of Materials used within the multi material.
  25211. * They need to be ordered according to the submeshes order in the associated mesh
  25212. */
  25213. get subMaterials(): Nullable<Material>[];
  25214. set subMaterials(value: Nullable<Material>[]);
  25215. /**
  25216. * Function used to align with Node.getChildren()
  25217. * @returns the list of Materials used within the multi material
  25218. */
  25219. getChildren(): Nullable<Material>[];
  25220. /**
  25221. * Instantiates a new Multi Material
  25222. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25223. * separate meshes. This can be use to improve performances.
  25224. * @see https://doc.babylonjs.com/how_to/multi_materials
  25225. * @param name Define the name in the scene
  25226. * @param scene Define the scene the material belongs to
  25227. */
  25228. constructor(name: string, scene: Scene);
  25229. private _hookArray;
  25230. /**
  25231. * Get one of the submaterial by its index in the submaterials array
  25232. * @param index The index to look the sub material at
  25233. * @returns The Material if the index has been defined
  25234. */
  25235. getSubMaterial(index: number): Nullable<Material>;
  25236. /**
  25237. * Get the list of active textures for the whole sub materials list.
  25238. * @returns All the textures that will be used during the rendering
  25239. */
  25240. getActiveTextures(): BaseTexture[];
  25241. /**
  25242. * Gets the current class name of the material e.g. "MultiMaterial"
  25243. * Mainly use in serialization.
  25244. * @returns the class name
  25245. */
  25246. getClassName(): string;
  25247. /**
  25248. * Checks if the material is ready to render the requested sub mesh
  25249. * @param mesh Define the mesh the submesh belongs to
  25250. * @param subMesh Define the sub mesh to look readyness for
  25251. * @param useInstances Define whether or not the material is used with instances
  25252. * @returns true if ready, otherwise false
  25253. */
  25254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25255. /**
  25256. * Clones the current material and its related sub materials
  25257. * @param name Define the name of the newly cloned material
  25258. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25259. * @returns the cloned material
  25260. */
  25261. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25262. /**
  25263. * Serializes the materials into a JSON representation.
  25264. * @returns the JSON representation
  25265. */
  25266. serialize(): any;
  25267. /**
  25268. * Dispose the material and release its associated resources
  25269. * @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)
  25270. * @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)
  25271. * @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)
  25272. */
  25273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25274. /**
  25275. * Creates a MultiMaterial from parsed MultiMaterial data.
  25276. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25277. * @param scene defines the hosting scene
  25278. * @returns a new MultiMaterial
  25279. */
  25280. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25281. }
  25282. }
  25283. declare module BABYLON {
  25284. /**
  25285. * Defines a subdivision inside a mesh
  25286. */
  25287. export class SubMesh implements ICullable {
  25288. /** the material index to use */
  25289. materialIndex: number;
  25290. /** vertex index start */
  25291. verticesStart: number;
  25292. /** vertices count */
  25293. verticesCount: number;
  25294. /** index start */
  25295. indexStart: number;
  25296. /** indices count */
  25297. indexCount: number;
  25298. /** @hidden */
  25299. _materialDefines: Nullable<MaterialDefines>;
  25300. /** @hidden */
  25301. _materialEffect: Nullable<Effect>;
  25302. /** @hidden */
  25303. _effectOverride: Nullable<Effect>;
  25304. /**
  25305. * Gets material defines used by the effect associated to the sub mesh
  25306. */
  25307. get materialDefines(): Nullable<MaterialDefines>;
  25308. /**
  25309. * Sets material defines used by the effect associated to the sub mesh
  25310. */
  25311. set materialDefines(defines: Nullable<MaterialDefines>);
  25312. /**
  25313. * Gets associated effect
  25314. */
  25315. get effect(): Nullable<Effect>;
  25316. /**
  25317. * Sets associated effect (effect used to render this submesh)
  25318. * @param effect defines the effect to associate with
  25319. * @param defines defines the set of defines used to compile this effect
  25320. */
  25321. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25322. /** @hidden */
  25323. _linesIndexCount: number;
  25324. private _mesh;
  25325. private _renderingMesh;
  25326. private _boundingInfo;
  25327. private _linesIndexBuffer;
  25328. /** @hidden */
  25329. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25330. /** @hidden */
  25331. _trianglePlanes: Plane[];
  25332. /** @hidden */
  25333. _lastColliderTransformMatrix: Nullable<Matrix>;
  25334. /** @hidden */
  25335. _renderId: number;
  25336. /** @hidden */
  25337. _alphaIndex: number;
  25338. /** @hidden */
  25339. _distanceToCamera: number;
  25340. /** @hidden */
  25341. _id: number;
  25342. private _currentMaterial;
  25343. /**
  25344. * Add a new submesh to a mesh
  25345. * @param materialIndex defines the material index to use
  25346. * @param verticesStart defines vertex index start
  25347. * @param verticesCount defines vertices count
  25348. * @param indexStart defines index start
  25349. * @param indexCount defines indices count
  25350. * @param mesh defines the parent mesh
  25351. * @param renderingMesh defines an optional rendering mesh
  25352. * @param createBoundingBox defines if bounding box should be created for this submesh
  25353. * @returns the new submesh
  25354. */
  25355. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25356. /**
  25357. * Creates a new submesh
  25358. * @param materialIndex defines the material index to use
  25359. * @param verticesStart defines vertex index start
  25360. * @param verticesCount defines vertices count
  25361. * @param indexStart defines index start
  25362. * @param indexCount defines indices count
  25363. * @param mesh defines the parent mesh
  25364. * @param renderingMesh defines an optional rendering mesh
  25365. * @param createBoundingBox defines if bounding box should be created for this submesh
  25366. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25367. */
  25368. constructor(
  25369. /** the material index to use */
  25370. materialIndex: number,
  25371. /** vertex index start */
  25372. verticesStart: number,
  25373. /** vertices count */
  25374. verticesCount: number,
  25375. /** index start */
  25376. indexStart: number,
  25377. /** indices count */
  25378. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25379. /**
  25380. * Returns true if this submesh covers the entire parent mesh
  25381. * @ignorenaming
  25382. */
  25383. get IsGlobal(): boolean;
  25384. /**
  25385. * Returns the submesh BoudingInfo object
  25386. * @returns current bounding info (or mesh's one if the submesh is global)
  25387. */
  25388. getBoundingInfo(): BoundingInfo;
  25389. /**
  25390. * Sets the submesh BoundingInfo
  25391. * @param boundingInfo defines the new bounding info to use
  25392. * @returns the SubMesh
  25393. */
  25394. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25395. /**
  25396. * Returns the mesh of the current submesh
  25397. * @return the parent mesh
  25398. */
  25399. getMesh(): AbstractMesh;
  25400. /**
  25401. * Returns the rendering mesh of the submesh
  25402. * @returns the rendering mesh (could be different from parent mesh)
  25403. */
  25404. getRenderingMesh(): Mesh;
  25405. /**
  25406. * Returns the replacement mesh of the submesh
  25407. * @returns the replacement mesh (could be different from parent mesh)
  25408. */
  25409. getReplacementMesh(): Nullable<AbstractMesh>;
  25410. /**
  25411. * Returns the effective mesh of the submesh
  25412. * @returns the effective mesh (could be different from parent mesh)
  25413. */
  25414. getEffectiveMesh(): AbstractMesh;
  25415. /**
  25416. * Returns the submesh material
  25417. * @returns null or the current material
  25418. */
  25419. getMaterial(): Nullable<Material>;
  25420. private _IsMultiMaterial;
  25421. /**
  25422. * Sets a new updated BoundingInfo object to the submesh
  25423. * @param data defines an optional position array to use to determine the bounding info
  25424. * @returns the SubMesh
  25425. */
  25426. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25427. /** @hidden */
  25428. _checkCollision(collider: Collider): boolean;
  25429. /**
  25430. * Updates the submesh BoundingInfo
  25431. * @param world defines the world matrix to use to update the bounding info
  25432. * @returns the submesh
  25433. */
  25434. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25435. /**
  25436. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25437. * @param frustumPlanes defines the frustum planes
  25438. * @returns true if the submesh is intersecting with the frustum
  25439. */
  25440. isInFrustum(frustumPlanes: Plane[]): boolean;
  25441. /**
  25442. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25443. * @param frustumPlanes defines the frustum planes
  25444. * @returns true if the submesh is inside the frustum
  25445. */
  25446. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25447. /**
  25448. * Renders the submesh
  25449. * @param enableAlphaMode defines if alpha needs to be used
  25450. * @returns the submesh
  25451. */
  25452. render(enableAlphaMode: boolean): SubMesh;
  25453. /**
  25454. * @hidden
  25455. */
  25456. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25457. /**
  25458. * Checks if the submesh intersects with a ray
  25459. * @param ray defines the ray to test
  25460. * @returns true is the passed ray intersects the submesh bounding box
  25461. */
  25462. canIntersects(ray: Ray): boolean;
  25463. /**
  25464. * Intersects current submesh with a ray
  25465. * @param ray defines the ray to test
  25466. * @param positions defines mesh's positions array
  25467. * @param indices defines mesh's indices array
  25468. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25469. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25470. * @returns intersection info or null if no intersection
  25471. */
  25472. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25473. /** @hidden */
  25474. private _intersectLines;
  25475. /** @hidden */
  25476. private _intersectUnIndexedLines;
  25477. /** @hidden */
  25478. private _intersectTriangles;
  25479. /** @hidden */
  25480. private _intersectUnIndexedTriangles;
  25481. /** @hidden */
  25482. _rebuild(): void;
  25483. /**
  25484. * Creates a new submesh from the passed mesh
  25485. * @param newMesh defines the new hosting mesh
  25486. * @param newRenderingMesh defines an optional rendering mesh
  25487. * @returns the new submesh
  25488. */
  25489. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25490. /**
  25491. * Release associated resources
  25492. */
  25493. dispose(): void;
  25494. /**
  25495. * Gets the class name
  25496. * @returns the string "SubMesh".
  25497. */
  25498. getClassName(): string;
  25499. /**
  25500. * Creates a new submesh from indices data
  25501. * @param materialIndex the index of the main mesh material
  25502. * @param startIndex the index where to start the copy in the mesh indices array
  25503. * @param indexCount the number of indices to copy then from the startIndex
  25504. * @param mesh the main mesh to create the submesh from
  25505. * @param renderingMesh the optional rendering mesh
  25506. * @returns a new submesh
  25507. */
  25508. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25509. }
  25510. }
  25511. declare module BABYLON {
  25512. /**
  25513. * Class used to represent data loading progression
  25514. */
  25515. export class SceneLoaderFlags {
  25516. private static _ForceFullSceneLoadingForIncremental;
  25517. private static _ShowLoadingScreen;
  25518. private static _CleanBoneMatrixWeights;
  25519. private static _loggingLevel;
  25520. /**
  25521. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25522. */
  25523. static get ForceFullSceneLoadingForIncremental(): boolean;
  25524. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25525. /**
  25526. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25527. */
  25528. static get ShowLoadingScreen(): boolean;
  25529. static set ShowLoadingScreen(value: boolean);
  25530. /**
  25531. * Defines the current logging level (while loading the scene)
  25532. * @ignorenaming
  25533. */
  25534. static get loggingLevel(): number;
  25535. static set loggingLevel(value: number);
  25536. /**
  25537. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25538. */
  25539. static get CleanBoneMatrixWeights(): boolean;
  25540. static set CleanBoneMatrixWeights(value: boolean);
  25541. }
  25542. }
  25543. declare module BABYLON {
  25544. /**
  25545. * Class used to store geometry data (vertex buffers + index buffer)
  25546. */
  25547. export class Geometry implements IGetSetVerticesData {
  25548. /**
  25549. * Gets or sets the ID of the geometry
  25550. */
  25551. id: string;
  25552. /**
  25553. * Gets or sets the unique ID of the geometry
  25554. */
  25555. uniqueId: number;
  25556. /**
  25557. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25558. */
  25559. delayLoadState: number;
  25560. /**
  25561. * Gets the file containing the data to load when running in delay load state
  25562. */
  25563. delayLoadingFile: Nullable<string>;
  25564. /**
  25565. * Callback called when the geometry is updated
  25566. */
  25567. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25568. private _scene;
  25569. private _engine;
  25570. private _meshes;
  25571. private _totalVertices;
  25572. /** @hidden */
  25573. _indices: IndicesArray;
  25574. /** @hidden */
  25575. _vertexBuffers: {
  25576. [key: string]: VertexBuffer;
  25577. };
  25578. private _isDisposed;
  25579. private _extend;
  25580. private _boundingBias;
  25581. /** @hidden */
  25582. _delayInfo: Array<string>;
  25583. private _indexBuffer;
  25584. private _indexBufferIsUpdatable;
  25585. /** @hidden */
  25586. _boundingInfo: Nullable<BoundingInfo>;
  25587. /** @hidden */
  25588. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25589. /** @hidden */
  25590. _softwareSkinningFrameId: number;
  25591. private _vertexArrayObjects;
  25592. private _updatable;
  25593. /** @hidden */
  25594. _positions: Nullable<Vector3[]>;
  25595. /**
  25596. * 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
  25597. */
  25598. get boundingBias(): Vector2;
  25599. /**
  25600. * 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
  25601. */
  25602. set boundingBias(value: Vector2);
  25603. /**
  25604. * Static function used to attach a new empty geometry to a mesh
  25605. * @param mesh defines the mesh to attach the geometry to
  25606. * @returns the new Geometry
  25607. */
  25608. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25609. /** Get the list of meshes using this geometry */
  25610. get meshes(): Mesh[];
  25611. /**
  25612. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  25613. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25614. */
  25615. useBoundingInfoFromGeometry: boolean;
  25616. /**
  25617. * Creates a new geometry
  25618. * @param id defines the unique ID
  25619. * @param scene defines the hosting scene
  25620. * @param vertexData defines the VertexData used to get geometry data
  25621. * @param updatable defines if geometry must be updatable (false by default)
  25622. * @param mesh defines the mesh that will be associated with the geometry
  25623. */
  25624. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25625. /**
  25626. * Gets the current extend of the geometry
  25627. */
  25628. get extend(): {
  25629. minimum: Vector3;
  25630. maximum: Vector3;
  25631. };
  25632. /**
  25633. * Gets the hosting scene
  25634. * @returns the hosting Scene
  25635. */
  25636. getScene(): Scene;
  25637. /**
  25638. * Gets the hosting engine
  25639. * @returns the hosting Engine
  25640. */
  25641. getEngine(): Engine;
  25642. /**
  25643. * Defines if the geometry is ready to use
  25644. * @returns true if the geometry is ready to be used
  25645. */
  25646. isReady(): boolean;
  25647. /**
  25648. * Gets a value indicating that the geometry should not be serialized
  25649. */
  25650. get doNotSerialize(): boolean;
  25651. /** @hidden */
  25652. _rebuild(): void;
  25653. /**
  25654. * Affects all geometry data in one call
  25655. * @param vertexData defines the geometry data
  25656. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25657. */
  25658. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25659. /**
  25660. * Set specific vertex data
  25661. * @param kind defines the data kind (Position, normal, etc...)
  25662. * @param data defines the vertex data to use
  25663. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25664. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25665. */
  25666. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25667. /**
  25668. * Removes a specific vertex data
  25669. * @param kind defines the data kind (Position, normal, etc...)
  25670. */
  25671. removeVerticesData(kind: string): void;
  25672. /**
  25673. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25674. * @param buffer defines the vertex buffer to use
  25675. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25676. */
  25677. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25678. /**
  25679. * Update a specific vertex buffer
  25680. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25681. * It will do nothing if the buffer is not updatable
  25682. * @param kind defines the data kind (Position, normal, etc...)
  25683. * @param data defines the data to use
  25684. * @param offset defines the offset in the target buffer where to store the data
  25685. * @param useBytes set to true if the offset is in bytes
  25686. */
  25687. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25688. /**
  25689. * Update a specific vertex buffer
  25690. * This function will create a new buffer if the current one is not updatable
  25691. * @param kind defines the data kind (Position, normal, etc...)
  25692. * @param data defines the data to use
  25693. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25694. */
  25695. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25696. private _updateBoundingInfo;
  25697. /** @hidden */
  25698. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25699. /**
  25700. * Gets total number of vertices
  25701. * @returns the total number of vertices
  25702. */
  25703. getTotalVertices(): number;
  25704. /**
  25705. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25706. * @param kind defines the data kind (Position, normal, etc...)
  25707. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25708. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25709. * @returns a float array containing vertex data
  25710. */
  25711. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25712. /**
  25713. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25714. * @param kind defines the data kind (Position, normal, etc...)
  25715. * @returns true if the vertex buffer with the specified kind is updatable
  25716. */
  25717. isVertexBufferUpdatable(kind: string): boolean;
  25718. /**
  25719. * Gets a specific vertex buffer
  25720. * @param kind defines the data kind (Position, normal, etc...)
  25721. * @returns a VertexBuffer
  25722. */
  25723. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25724. /**
  25725. * Returns all vertex buffers
  25726. * @return an object holding all vertex buffers indexed by kind
  25727. */
  25728. getVertexBuffers(): Nullable<{
  25729. [key: string]: VertexBuffer;
  25730. }>;
  25731. /**
  25732. * Gets a boolean indicating if specific vertex buffer is present
  25733. * @param kind defines the data kind (Position, normal, etc...)
  25734. * @returns true if data is present
  25735. */
  25736. isVerticesDataPresent(kind: string): boolean;
  25737. /**
  25738. * Gets a list of all attached data kinds (Position, normal, etc...)
  25739. * @returns a list of string containing all kinds
  25740. */
  25741. getVerticesDataKinds(): string[];
  25742. /**
  25743. * Update index buffer
  25744. * @param indices defines the indices to store in the index buffer
  25745. * @param offset defines the offset in the target buffer where to store the data
  25746. * @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)
  25747. */
  25748. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25749. /**
  25750. * Creates a new index buffer
  25751. * @param indices defines the indices to store in the index buffer
  25752. * @param totalVertices defines the total number of vertices (could be null)
  25753. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25754. */
  25755. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25756. /**
  25757. * Return the total number of indices
  25758. * @returns the total number of indices
  25759. */
  25760. getTotalIndices(): number;
  25761. /**
  25762. * Gets the index buffer array
  25763. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25764. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25765. * @returns the index buffer array
  25766. */
  25767. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25768. /**
  25769. * Gets the index buffer
  25770. * @return the index buffer
  25771. */
  25772. getIndexBuffer(): Nullable<DataBuffer>;
  25773. /** @hidden */
  25774. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25775. /**
  25776. * Release the associated resources for a specific mesh
  25777. * @param mesh defines the source mesh
  25778. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25779. */
  25780. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25781. /**
  25782. * Apply current geometry to a given mesh
  25783. * @param mesh defines the mesh to apply geometry to
  25784. */
  25785. applyToMesh(mesh: Mesh): void;
  25786. private _updateExtend;
  25787. private _applyToMesh;
  25788. private notifyUpdate;
  25789. /**
  25790. * Load the geometry if it was flagged as delay loaded
  25791. * @param scene defines the hosting scene
  25792. * @param onLoaded defines a callback called when the geometry is loaded
  25793. */
  25794. load(scene: Scene, onLoaded?: () => void): void;
  25795. private _queueLoad;
  25796. /**
  25797. * Invert the geometry to move from a right handed system to a left handed one.
  25798. */
  25799. toLeftHanded(): void;
  25800. /** @hidden */
  25801. _resetPointsArrayCache(): void;
  25802. /** @hidden */
  25803. _generatePointsArray(): boolean;
  25804. /**
  25805. * Gets a value indicating if the geometry is disposed
  25806. * @returns true if the geometry was disposed
  25807. */
  25808. isDisposed(): boolean;
  25809. private _disposeVertexArrayObjects;
  25810. /**
  25811. * Free all associated resources
  25812. */
  25813. dispose(): void;
  25814. /**
  25815. * Clone the current geometry into a new geometry
  25816. * @param id defines the unique ID of the new geometry
  25817. * @returns a new geometry object
  25818. */
  25819. copy(id: string): Geometry;
  25820. /**
  25821. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25822. * @return a JSON representation of the current geometry data (without the vertices data)
  25823. */
  25824. serialize(): any;
  25825. private toNumberArray;
  25826. /**
  25827. * Serialize all vertices data into a JSON oject
  25828. * @returns a JSON representation of the current geometry data
  25829. */
  25830. serializeVerticeData(): any;
  25831. /**
  25832. * Extracts a clone of a mesh geometry
  25833. * @param mesh defines the source mesh
  25834. * @param id defines the unique ID of the new geometry object
  25835. * @returns the new geometry object
  25836. */
  25837. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25838. /**
  25839. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25840. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25841. * Be aware Math.random() could cause collisions, but:
  25842. * "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"
  25843. * @returns a string containing a new GUID
  25844. */
  25845. static RandomId(): string;
  25846. /** @hidden */
  25847. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25848. private static _CleanMatricesWeights;
  25849. /**
  25850. * Create a new geometry from persisted data (Using .babylon file format)
  25851. * @param parsedVertexData defines the persisted data
  25852. * @param scene defines the hosting scene
  25853. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25854. * @returns the new geometry object
  25855. */
  25856. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25857. }
  25858. }
  25859. declare module BABYLON {
  25860. /**
  25861. * Define an interface for all classes that will get and set the data on vertices
  25862. */
  25863. export interface IGetSetVerticesData {
  25864. /**
  25865. * Gets a boolean indicating if specific vertex data is present
  25866. * @param kind defines the vertex data kind to use
  25867. * @returns true is data kind is present
  25868. */
  25869. isVerticesDataPresent(kind: string): boolean;
  25870. /**
  25871. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25872. * @param kind defines the data kind (Position, normal, etc...)
  25873. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25874. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25875. * @returns a float array containing vertex data
  25876. */
  25877. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25878. /**
  25879. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25880. * @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.
  25881. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25882. * @returns the indices array or an empty array if the mesh has no geometry
  25883. */
  25884. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25885. /**
  25886. * Set specific vertex data
  25887. * @param kind defines the data kind (Position, normal, etc...)
  25888. * @param data defines the vertex data to use
  25889. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25890. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25891. */
  25892. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25893. /**
  25894. * Update a specific associated vertex buffer
  25895. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25896. * - VertexBuffer.PositionKind
  25897. * - VertexBuffer.UVKind
  25898. * - VertexBuffer.UV2Kind
  25899. * - VertexBuffer.UV3Kind
  25900. * - VertexBuffer.UV4Kind
  25901. * - VertexBuffer.UV5Kind
  25902. * - VertexBuffer.UV6Kind
  25903. * - VertexBuffer.ColorKind
  25904. * - VertexBuffer.MatricesIndicesKind
  25905. * - VertexBuffer.MatricesIndicesExtraKind
  25906. * - VertexBuffer.MatricesWeightsKind
  25907. * - VertexBuffer.MatricesWeightsExtraKind
  25908. * @param data defines the data source
  25909. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25910. * @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)
  25911. */
  25912. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25913. /**
  25914. * Creates a new index buffer
  25915. * @param indices defines the indices to store in the index buffer
  25916. * @param totalVertices defines the total number of vertices (could be null)
  25917. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25918. */
  25919. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25920. }
  25921. /**
  25922. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25923. */
  25924. export class VertexData {
  25925. /**
  25926. * Mesh side orientation : usually the external or front surface
  25927. */
  25928. static readonly FRONTSIDE: number;
  25929. /**
  25930. * Mesh side orientation : usually the internal or back surface
  25931. */
  25932. static readonly BACKSIDE: number;
  25933. /**
  25934. * Mesh side orientation : both internal and external or front and back surfaces
  25935. */
  25936. static readonly DOUBLESIDE: number;
  25937. /**
  25938. * Mesh side orientation : by default, `FRONTSIDE`
  25939. */
  25940. static readonly DEFAULTSIDE: number;
  25941. /**
  25942. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25943. */
  25944. positions: Nullable<FloatArray>;
  25945. /**
  25946. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25947. */
  25948. normals: Nullable<FloatArray>;
  25949. /**
  25950. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25951. */
  25952. tangents: Nullable<FloatArray>;
  25953. /**
  25954. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25955. */
  25956. uvs: Nullable<FloatArray>;
  25957. /**
  25958. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25959. */
  25960. uvs2: Nullable<FloatArray>;
  25961. /**
  25962. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25963. */
  25964. uvs3: Nullable<FloatArray>;
  25965. /**
  25966. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25967. */
  25968. uvs4: Nullable<FloatArray>;
  25969. /**
  25970. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25971. */
  25972. uvs5: Nullable<FloatArray>;
  25973. /**
  25974. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25975. */
  25976. uvs6: Nullable<FloatArray>;
  25977. /**
  25978. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25979. */
  25980. colors: Nullable<FloatArray>;
  25981. /**
  25982. * 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).
  25983. */
  25984. matricesIndices: Nullable<FloatArray>;
  25985. /**
  25986. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25987. */
  25988. matricesWeights: Nullable<FloatArray>;
  25989. /**
  25990. * An array extending the number of possible indices
  25991. */
  25992. matricesIndicesExtra: Nullable<FloatArray>;
  25993. /**
  25994. * An array extending the number of possible weights when the number of indices is extended
  25995. */
  25996. matricesWeightsExtra: Nullable<FloatArray>;
  25997. /**
  25998. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25999. */
  26000. indices: Nullable<IndicesArray>;
  26001. /**
  26002. * Uses the passed data array to set the set the values for the specified kind of data
  26003. * @param data a linear array of floating numbers
  26004. * @param kind the type of data that is being set, eg positions, colors etc
  26005. */
  26006. set(data: FloatArray, kind: string): void;
  26007. /**
  26008. * Associates the vertexData to the passed Mesh.
  26009. * Sets it as updatable or not (default `false`)
  26010. * @param mesh the mesh the vertexData is applied to
  26011. * @param updatable when used and having the value true allows new data to update the vertexData
  26012. * @returns the VertexData
  26013. */
  26014. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26015. /**
  26016. * Associates the vertexData to the passed Geometry.
  26017. * Sets it as updatable or not (default `false`)
  26018. * @param geometry the geometry the vertexData is applied to
  26019. * @param updatable when used and having the value true allows new data to update the vertexData
  26020. * @returns VertexData
  26021. */
  26022. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26023. /**
  26024. * Updates the associated mesh
  26025. * @param mesh the mesh to be updated
  26026. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26027. * @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
  26028. * @returns VertexData
  26029. */
  26030. updateMesh(mesh: Mesh): VertexData;
  26031. /**
  26032. * Updates the associated geometry
  26033. * @param geometry the geometry to be updated
  26034. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26035. * @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
  26036. * @returns VertexData.
  26037. */
  26038. updateGeometry(geometry: Geometry): VertexData;
  26039. private _applyTo;
  26040. private _update;
  26041. /**
  26042. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26043. * @param matrix the transforming matrix
  26044. * @returns the VertexData
  26045. */
  26046. transform(matrix: Matrix): VertexData;
  26047. /**
  26048. * Merges the passed VertexData into the current one
  26049. * @param other the VertexData to be merged into the current one
  26050. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26051. * @returns the modified VertexData
  26052. */
  26053. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26054. private _mergeElement;
  26055. private _validate;
  26056. /**
  26057. * Serializes the VertexData
  26058. * @returns a serialized object
  26059. */
  26060. serialize(): any;
  26061. /**
  26062. * Extracts the vertexData from a mesh
  26063. * @param mesh the mesh from which to extract the VertexData
  26064. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26065. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26066. * @returns the object VertexData associated to the passed mesh
  26067. */
  26068. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26069. /**
  26070. * Extracts the vertexData from the geometry
  26071. * @param geometry the geometry from which to extract the VertexData
  26072. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26073. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26074. * @returns the object VertexData associated to the passed mesh
  26075. */
  26076. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26077. private static _ExtractFrom;
  26078. /**
  26079. * Creates the VertexData for a Ribbon
  26080. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26081. * * pathArray array of paths, each of which an array of successive Vector3
  26082. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26083. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26084. * * 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
  26085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26086. * * 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)
  26087. * * 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)
  26088. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26089. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26090. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26091. * @returns the VertexData of the ribbon
  26092. */
  26093. static CreateRibbon(options: {
  26094. pathArray: Vector3[][];
  26095. closeArray?: boolean;
  26096. closePath?: boolean;
  26097. offset?: number;
  26098. sideOrientation?: number;
  26099. frontUVs?: Vector4;
  26100. backUVs?: Vector4;
  26101. invertUV?: boolean;
  26102. uvs?: Vector2[];
  26103. colors?: Color4[];
  26104. }): VertexData;
  26105. /**
  26106. * Creates the VertexData for a box
  26107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26108. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26109. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26110. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26111. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26112. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26113. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26115. * * 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)
  26116. * * 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)
  26117. * @returns the VertexData of the box
  26118. */
  26119. static CreateBox(options: {
  26120. size?: number;
  26121. width?: number;
  26122. height?: number;
  26123. depth?: number;
  26124. faceUV?: Vector4[];
  26125. faceColors?: Color4[];
  26126. sideOrientation?: number;
  26127. frontUVs?: Vector4;
  26128. backUVs?: Vector4;
  26129. }): VertexData;
  26130. /**
  26131. * Creates the VertexData for a tiled box
  26132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26133. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26134. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26135. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26137. * @returns the VertexData of the box
  26138. */
  26139. static CreateTiledBox(options: {
  26140. pattern?: number;
  26141. width?: number;
  26142. height?: number;
  26143. depth?: number;
  26144. tileSize?: number;
  26145. tileWidth?: number;
  26146. tileHeight?: number;
  26147. alignHorizontal?: number;
  26148. alignVertical?: number;
  26149. faceUV?: Vector4[];
  26150. faceColors?: Color4[];
  26151. sideOrientation?: number;
  26152. }): VertexData;
  26153. /**
  26154. * Creates the VertexData for a tiled plane
  26155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26156. * * pattern a limited pattern arrangement depending on the number
  26157. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26158. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26159. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26161. * * 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)
  26162. * * 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)
  26163. * @returns the VertexData of the tiled plane
  26164. */
  26165. static CreateTiledPlane(options: {
  26166. pattern?: number;
  26167. tileSize?: number;
  26168. tileWidth?: number;
  26169. tileHeight?: number;
  26170. size?: number;
  26171. width?: number;
  26172. height?: number;
  26173. alignHorizontal?: number;
  26174. alignVertical?: number;
  26175. sideOrientation?: number;
  26176. frontUVs?: Vector4;
  26177. backUVs?: Vector4;
  26178. }): VertexData;
  26179. /**
  26180. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26182. * * segments sets the number of horizontal strips optional, default 32
  26183. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26184. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26185. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26186. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26187. * * 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
  26188. * * 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
  26189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26190. * * 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)
  26191. * * 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)
  26192. * @returns the VertexData of the ellipsoid
  26193. */
  26194. static CreateSphere(options: {
  26195. segments?: number;
  26196. diameter?: number;
  26197. diameterX?: number;
  26198. diameterY?: number;
  26199. diameterZ?: number;
  26200. arc?: number;
  26201. slice?: number;
  26202. sideOrientation?: number;
  26203. frontUVs?: Vector4;
  26204. backUVs?: Vector4;
  26205. }): VertexData;
  26206. /**
  26207. * Creates the VertexData for a cylinder, cone or prism
  26208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26209. * * height sets the height (y direction) of the cylinder, optional, default 2
  26210. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26211. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26212. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26213. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26214. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26215. * * 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
  26216. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26217. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26218. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26219. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26221. * * 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)
  26222. * * 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)
  26223. * @returns the VertexData of the cylinder, cone or prism
  26224. */
  26225. static CreateCylinder(options: {
  26226. height?: number;
  26227. diameterTop?: number;
  26228. diameterBottom?: number;
  26229. diameter?: number;
  26230. tessellation?: number;
  26231. subdivisions?: number;
  26232. arc?: number;
  26233. faceColors?: Color4[];
  26234. faceUV?: Vector4[];
  26235. hasRings?: boolean;
  26236. enclose?: boolean;
  26237. sideOrientation?: number;
  26238. frontUVs?: Vector4;
  26239. backUVs?: Vector4;
  26240. }): VertexData;
  26241. /**
  26242. * Creates the VertexData for a torus
  26243. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26244. * * diameter the diameter of the torus, optional default 1
  26245. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26246. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26248. * * 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)
  26249. * * 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)
  26250. * @returns the VertexData of the torus
  26251. */
  26252. static CreateTorus(options: {
  26253. diameter?: number;
  26254. thickness?: number;
  26255. tessellation?: number;
  26256. sideOrientation?: number;
  26257. frontUVs?: Vector4;
  26258. backUVs?: Vector4;
  26259. }): VertexData;
  26260. /**
  26261. * Creates the VertexData of the LineSystem
  26262. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26263. * - lines an array of lines, each line being an array of successive Vector3
  26264. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26265. * @returns the VertexData of the LineSystem
  26266. */
  26267. static CreateLineSystem(options: {
  26268. lines: Vector3[][];
  26269. colors?: Nullable<Color4[][]>;
  26270. }): VertexData;
  26271. /**
  26272. * Create the VertexData for a DashedLines
  26273. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26274. * - points an array successive Vector3
  26275. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26276. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26277. * - dashNb the intended total number of dashes, optional, default 200
  26278. * @returns the VertexData for the DashedLines
  26279. */
  26280. static CreateDashedLines(options: {
  26281. points: Vector3[];
  26282. dashSize?: number;
  26283. gapSize?: number;
  26284. dashNb?: number;
  26285. }): VertexData;
  26286. /**
  26287. * Creates the VertexData for a Ground
  26288. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26289. * - width the width (x direction) of the ground, optional, default 1
  26290. * - height the height (z direction) of the ground, optional, default 1
  26291. * - subdivisions the number of subdivisions per side, optional, default 1
  26292. * @returns the VertexData of the Ground
  26293. */
  26294. static CreateGround(options: {
  26295. width?: number;
  26296. height?: number;
  26297. subdivisions?: number;
  26298. subdivisionsX?: number;
  26299. subdivisionsY?: number;
  26300. }): VertexData;
  26301. /**
  26302. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26303. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26304. * * xmin the ground minimum X coordinate, optional, default -1
  26305. * * zmin the ground minimum Z coordinate, optional, default -1
  26306. * * xmax the ground maximum X coordinate, optional, default 1
  26307. * * zmax the ground maximum Z coordinate, optional, default 1
  26308. * * 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}
  26309. * * 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}
  26310. * @returns the VertexData of the TiledGround
  26311. */
  26312. static CreateTiledGround(options: {
  26313. xmin: number;
  26314. zmin: number;
  26315. xmax: number;
  26316. zmax: number;
  26317. subdivisions?: {
  26318. w: number;
  26319. h: number;
  26320. };
  26321. precision?: {
  26322. w: number;
  26323. h: number;
  26324. };
  26325. }): VertexData;
  26326. /**
  26327. * Creates the VertexData of the Ground designed from a heightmap
  26328. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26329. * * width the width (x direction) of the ground
  26330. * * height the height (z direction) of the ground
  26331. * * subdivisions the number of subdivisions per side
  26332. * * minHeight the minimum altitude on the ground, optional, default 0
  26333. * * maxHeight the maximum altitude on the ground, optional default 1
  26334. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26335. * * buffer the array holding the image color data
  26336. * * bufferWidth the width of image
  26337. * * bufferHeight the height of image
  26338. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26339. * @returns the VertexData of the Ground designed from a heightmap
  26340. */
  26341. static CreateGroundFromHeightMap(options: {
  26342. width: number;
  26343. height: number;
  26344. subdivisions: number;
  26345. minHeight: number;
  26346. maxHeight: number;
  26347. colorFilter: Color3;
  26348. buffer: Uint8Array;
  26349. bufferWidth: number;
  26350. bufferHeight: number;
  26351. alphaFilter: number;
  26352. }): VertexData;
  26353. /**
  26354. * Creates the VertexData for a Plane
  26355. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26356. * * size sets the width and height of the plane to the value of size, optional default 1
  26357. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26358. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26360. * * 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)
  26361. * * 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)
  26362. * @returns the VertexData of the box
  26363. */
  26364. static CreatePlane(options: {
  26365. size?: number;
  26366. width?: number;
  26367. height?: number;
  26368. sideOrientation?: number;
  26369. frontUVs?: Vector4;
  26370. backUVs?: Vector4;
  26371. }): VertexData;
  26372. /**
  26373. * Creates the VertexData of the Disc or regular Polygon
  26374. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26375. * * radius the radius of the disc, optional default 0.5
  26376. * * tessellation the number of polygon sides, optional, default 64
  26377. * * 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
  26378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26379. * * 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)
  26380. * * 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)
  26381. * @returns the VertexData of the box
  26382. */
  26383. static CreateDisc(options: {
  26384. radius?: number;
  26385. tessellation?: number;
  26386. arc?: number;
  26387. sideOrientation?: number;
  26388. frontUVs?: Vector4;
  26389. backUVs?: Vector4;
  26390. }): VertexData;
  26391. /**
  26392. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26393. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26394. * @param polygon a mesh built from polygonTriangulation.build()
  26395. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26396. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26397. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26398. * @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)
  26399. * @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)
  26400. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26401. * @returns the VertexData of the Polygon
  26402. */
  26403. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26404. /**
  26405. * Creates the VertexData of the IcoSphere
  26406. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26407. * * radius the radius of the IcoSphere, optional default 1
  26408. * * radiusX allows stretching in the x direction, optional, default radius
  26409. * * radiusY allows stretching in the y direction, optional, default radius
  26410. * * radiusZ allows stretching in the z direction, optional, default radius
  26411. * * flat when true creates a flat shaded mesh, optional, default true
  26412. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26414. * * 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)
  26415. * * 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)
  26416. * @returns the VertexData of the IcoSphere
  26417. */
  26418. static CreateIcoSphere(options: {
  26419. radius?: number;
  26420. radiusX?: number;
  26421. radiusY?: number;
  26422. radiusZ?: number;
  26423. flat?: boolean;
  26424. subdivisions?: number;
  26425. sideOrientation?: number;
  26426. frontUVs?: Vector4;
  26427. backUVs?: Vector4;
  26428. }): VertexData;
  26429. /**
  26430. * Creates the VertexData for a Polyhedron
  26431. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26432. * * type provided types are:
  26433. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26434. * * 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)
  26435. * * size the size of the IcoSphere, optional default 1
  26436. * * sizeX allows stretching in the x direction, optional, default size
  26437. * * sizeY allows stretching in the y direction, optional, default size
  26438. * * sizeZ allows stretching in the z direction, optional, default size
  26439. * * 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
  26440. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26441. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26442. * * flat when true creates a flat shaded mesh, optional, default true
  26443. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26445. * * 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)
  26446. * * 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)
  26447. * @returns the VertexData of the Polyhedron
  26448. */
  26449. static CreatePolyhedron(options: {
  26450. type?: number;
  26451. size?: number;
  26452. sizeX?: number;
  26453. sizeY?: number;
  26454. sizeZ?: number;
  26455. custom?: any;
  26456. faceUV?: Vector4[];
  26457. faceColors?: Color4[];
  26458. flat?: boolean;
  26459. sideOrientation?: number;
  26460. frontUVs?: Vector4;
  26461. backUVs?: Vector4;
  26462. }): VertexData;
  26463. /**
  26464. * Creates the VertexData for a TorusKnot
  26465. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26466. * * radius the radius of the torus knot, optional, default 2
  26467. * * tube the thickness of the tube, optional, default 0.5
  26468. * * radialSegments the number of sides on each tube segments, optional, default 32
  26469. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26470. * * p the number of windings around the z axis, optional, default 2
  26471. * * q the number of windings around the x axis, optional, default 3
  26472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26473. * * 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)
  26474. * * 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)
  26475. * @returns the VertexData of the Torus Knot
  26476. */
  26477. static CreateTorusKnot(options: {
  26478. radius?: number;
  26479. tube?: number;
  26480. radialSegments?: number;
  26481. tubularSegments?: number;
  26482. p?: number;
  26483. q?: number;
  26484. sideOrientation?: number;
  26485. frontUVs?: Vector4;
  26486. backUVs?: Vector4;
  26487. }): VertexData;
  26488. /**
  26489. * Compute normals for given positions and indices
  26490. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26491. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26492. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26493. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26494. * * facetNormals : optional array of facet normals (vector3)
  26495. * * facetPositions : optional array of facet positions (vector3)
  26496. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26497. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26498. * * bInfo : optional bounding info, required for facetPartitioning computation
  26499. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26500. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26501. * * useRightHandedSystem: optional boolean to for right handed system computation
  26502. * * depthSort : optional boolean to enable the facet depth sort computation
  26503. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26504. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26505. */
  26506. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26507. facetNormals?: any;
  26508. facetPositions?: any;
  26509. facetPartitioning?: any;
  26510. ratio?: number;
  26511. bInfo?: any;
  26512. bbSize?: Vector3;
  26513. subDiv?: any;
  26514. useRightHandedSystem?: boolean;
  26515. depthSort?: boolean;
  26516. distanceTo?: Vector3;
  26517. depthSortedFacets?: any;
  26518. }): void;
  26519. /** @hidden */
  26520. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26521. /**
  26522. * Applies VertexData created from the imported parameters to the geometry
  26523. * @param parsedVertexData the parsed data from an imported file
  26524. * @param geometry the geometry to apply the VertexData to
  26525. */
  26526. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26527. }
  26528. }
  26529. declare module BABYLON {
  26530. /**
  26531. * Defines a target to use with MorphTargetManager
  26532. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26533. */
  26534. export class MorphTarget implements IAnimatable {
  26535. /** defines the name of the target */
  26536. name: string;
  26537. /**
  26538. * Gets or sets the list of animations
  26539. */
  26540. animations: Animation[];
  26541. private _scene;
  26542. private _positions;
  26543. private _normals;
  26544. private _tangents;
  26545. private _uvs;
  26546. private _influence;
  26547. private _uniqueId;
  26548. /**
  26549. * Observable raised when the influence changes
  26550. */
  26551. onInfluenceChanged: Observable<boolean>;
  26552. /** @hidden */
  26553. _onDataLayoutChanged: Observable<void>;
  26554. /**
  26555. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26556. */
  26557. get influence(): number;
  26558. set influence(influence: number);
  26559. /**
  26560. * Gets or sets the id of the morph Target
  26561. */
  26562. id: string;
  26563. private _animationPropertiesOverride;
  26564. /**
  26565. * Gets or sets the animation properties override
  26566. */
  26567. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26568. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26569. /**
  26570. * Creates a new MorphTarget
  26571. * @param name defines the name of the target
  26572. * @param influence defines the influence to use
  26573. * @param scene defines the scene the morphtarget belongs to
  26574. */
  26575. constructor(
  26576. /** defines the name of the target */
  26577. name: string, influence?: number, scene?: Nullable<Scene>);
  26578. /**
  26579. * Gets the unique ID of this manager
  26580. */
  26581. get uniqueId(): number;
  26582. /**
  26583. * Gets a boolean defining if the target contains position data
  26584. */
  26585. get hasPositions(): boolean;
  26586. /**
  26587. * Gets a boolean defining if the target contains normal data
  26588. */
  26589. get hasNormals(): boolean;
  26590. /**
  26591. * Gets a boolean defining if the target contains tangent data
  26592. */
  26593. get hasTangents(): boolean;
  26594. /**
  26595. * Gets a boolean defining if the target contains texture coordinates data
  26596. */
  26597. get hasUVs(): boolean;
  26598. /**
  26599. * Affects position data to this target
  26600. * @param data defines the position data to use
  26601. */
  26602. setPositions(data: Nullable<FloatArray>): void;
  26603. /**
  26604. * Gets the position data stored in this target
  26605. * @returns a FloatArray containing the position data (or null if not present)
  26606. */
  26607. getPositions(): Nullable<FloatArray>;
  26608. /**
  26609. * Affects normal data to this target
  26610. * @param data defines the normal data to use
  26611. */
  26612. setNormals(data: Nullable<FloatArray>): void;
  26613. /**
  26614. * Gets the normal data stored in this target
  26615. * @returns a FloatArray containing the normal data (or null if not present)
  26616. */
  26617. getNormals(): Nullable<FloatArray>;
  26618. /**
  26619. * Affects tangent data to this target
  26620. * @param data defines the tangent data to use
  26621. */
  26622. setTangents(data: Nullable<FloatArray>): void;
  26623. /**
  26624. * Gets the tangent data stored in this target
  26625. * @returns a FloatArray containing the tangent data (or null if not present)
  26626. */
  26627. getTangents(): Nullable<FloatArray>;
  26628. /**
  26629. * Affects texture coordinates data to this target
  26630. * @param data defines the texture coordinates data to use
  26631. */
  26632. setUVs(data: Nullable<FloatArray>): void;
  26633. /**
  26634. * Gets the texture coordinates data stored in this target
  26635. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26636. */
  26637. getUVs(): Nullable<FloatArray>;
  26638. /**
  26639. * Clone the current target
  26640. * @returns a new MorphTarget
  26641. */
  26642. clone(): MorphTarget;
  26643. /**
  26644. * Serializes the current target into a Serialization object
  26645. * @returns the serialized object
  26646. */
  26647. serialize(): any;
  26648. /**
  26649. * Returns the string "MorphTarget"
  26650. * @returns "MorphTarget"
  26651. */
  26652. getClassName(): string;
  26653. /**
  26654. * Creates a new target from serialized data
  26655. * @param serializationObject defines the serialized data to use
  26656. * @returns a new MorphTarget
  26657. */
  26658. static Parse(serializationObject: any): MorphTarget;
  26659. /**
  26660. * Creates a MorphTarget from mesh data
  26661. * @param mesh defines the source mesh
  26662. * @param name defines the name to use for the new target
  26663. * @param influence defines the influence to attach to the target
  26664. * @returns a new MorphTarget
  26665. */
  26666. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26667. }
  26668. }
  26669. declare module BABYLON {
  26670. /**
  26671. * This class is used to deform meshes using morphing between different targets
  26672. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26673. */
  26674. export class MorphTargetManager {
  26675. private _targets;
  26676. private _targetInfluenceChangedObservers;
  26677. private _targetDataLayoutChangedObservers;
  26678. private _activeTargets;
  26679. private _scene;
  26680. private _influences;
  26681. private _supportsNormals;
  26682. private _supportsTangents;
  26683. private _supportsUVs;
  26684. private _vertexCount;
  26685. private _uniqueId;
  26686. private _tempInfluences;
  26687. /**
  26688. * Gets or sets a boolean indicating if normals must be morphed
  26689. */
  26690. enableNormalMorphing: boolean;
  26691. /**
  26692. * Gets or sets a boolean indicating if tangents must be morphed
  26693. */
  26694. enableTangentMorphing: boolean;
  26695. /**
  26696. * Gets or sets a boolean indicating if UV must be morphed
  26697. */
  26698. enableUVMorphing: boolean;
  26699. /**
  26700. * Creates a new MorphTargetManager
  26701. * @param scene defines the current scene
  26702. */
  26703. constructor(scene?: Nullable<Scene>);
  26704. /**
  26705. * Gets the unique ID of this manager
  26706. */
  26707. get uniqueId(): number;
  26708. /**
  26709. * Gets the number of vertices handled by this manager
  26710. */
  26711. get vertexCount(): number;
  26712. /**
  26713. * Gets a boolean indicating if this manager supports morphing of normals
  26714. */
  26715. get supportsNormals(): boolean;
  26716. /**
  26717. * Gets a boolean indicating if this manager supports morphing of tangents
  26718. */
  26719. get supportsTangents(): boolean;
  26720. /**
  26721. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26722. */
  26723. get supportsUVs(): boolean;
  26724. /**
  26725. * Gets the number of targets stored in this manager
  26726. */
  26727. get numTargets(): number;
  26728. /**
  26729. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26730. */
  26731. get numInfluencers(): number;
  26732. /**
  26733. * Gets the list of influences (one per target)
  26734. */
  26735. get influences(): Float32Array;
  26736. /**
  26737. * Gets the active target at specified index. An active target is a target with an influence > 0
  26738. * @param index defines the index to check
  26739. * @returns the requested target
  26740. */
  26741. getActiveTarget(index: number): MorphTarget;
  26742. /**
  26743. * Gets the target at specified index
  26744. * @param index defines the index to check
  26745. * @returns the requested target
  26746. */
  26747. getTarget(index: number): MorphTarget;
  26748. /**
  26749. * Add a new target to this manager
  26750. * @param target defines the target to add
  26751. */
  26752. addTarget(target: MorphTarget): void;
  26753. /**
  26754. * Removes a target from the manager
  26755. * @param target defines the target to remove
  26756. */
  26757. removeTarget(target: MorphTarget): void;
  26758. /**
  26759. * Clone the current manager
  26760. * @returns a new MorphTargetManager
  26761. */
  26762. clone(): MorphTargetManager;
  26763. /**
  26764. * Serializes the current manager into a Serialization object
  26765. * @returns the serialized object
  26766. */
  26767. serialize(): any;
  26768. private _syncActiveTargets;
  26769. /**
  26770. * Syncrhonize the targets with all the meshes using this morph target manager
  26771. */
  26772. synchronize(): void;
  26773. /**
  26774. * Creates a new MorphTargetManager from serialized data
  26775. * @param serializationObject defines the serialized data
  26776. * @param scene defines the hosting scene
  26777. * @returns the new MorphTargetManager
  26778. */
  26779. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26780. }
  26781. }
  26782. declare module BABYLON {
  26783. /**
  26784. * Class used to represent a specific level of detail of a mesh
  26785. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26786. */
  26787. export class MeshLODLevel {
  26788. /** Defines the distance where this level should start being displayed */
  26789. distance: number;
  26790. /** Defines the mesh to use to render this level */
  26791. mesh: Nullable<Mesh>;
  26792. /**
  26793. * Creates a new LOD level
  26794. * @param distance defines the distance where this level should star being displayed
  26795. * @param mesh defines the mesh to use to render this level
  26796. */
  26797. constructor(
  26798. /** Defines the distance where this level should start being displayed */
  26799. distance: number,
  26800. /** Defines the mesh to use to render this level */
  26801. mesh: Nullable<Mesh>);
  26802. }
  26803. }
  26804. declare module BABYLON {
  26805. /**
  26806. * Helper class used to generate a canvas to manipulate images
  26807. */
  26808. export class CanvasGenerator {
  26809. /**
  26810. * Create a new canvas (or offscreen canvas depending on the context)
  26811. * @param width defines the expected width
  26812. * @param height defines the expected height
  26813. * @return a new canvas or offscreen canvas
  26814. */
  26815. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26816. }
  26817. }
  26818. declare module BABYLON {
  26819. /**
  26820. * Mesh representing the gorund
  26821. */
  26822. export class GroundMesh extends Mesh {
  26823. /** If octree should be generated */
  26824. generateOctree: boolean;
  26825. private _heightQuads;
  26826. /** @hidden */
  26827. _subdivisionsX: number;
  26828. /** @hidden */
  26829. _subdivisionsY: number;
  26830. /** @hidden */
  26831. _width: number;
  26832. /** @hidden */
  26833. _height: number;
  26834. /** @hidden */
  26835. _minX: number;
  26836. /** @hidden */
  26837. _maxX: number;
  26838. /** @hidden */
  26839. _minZ: number;
  26840. /** @hidden */
  26841. _maxZ: number;
  26842. constructor(name: string, scene: Scene);
  26843. /**
  26844. * "GroundMesh"
  26845. * @returns "GroundMesh"
  26846. */
  26847. getClassName(): string;
  26848. /**
  26849. * The minimum of x and y subdivisions
  26850. */
  26851. get subdivisions(): number;
  26852. /**
  26853. * X subdivisions
  26854. */
  26855. get subdivisionsX(): number;
  26856. /**
  26857. * Y subdivisions
  26858. */
  26859. get subdivisionsY(): number;
  26860. /**
  26861. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26862. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26863. * @param chunksCount the number of subdivisions for x and y
  26864. * @param octreeBlocksSize (Default: 32)
  26865. */
  26866. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26867. /**
  26868. * Returns a height (y) value in the Worl system :
  26869. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26870. * @param x x coordinate
  26871. * @param z z coordinate
  26872. * @returns the ground y position if (x, z) are outside the ground surface.
  26873. */
  26874. getHeightAtCoordinates(x: number, z: number): number;
  26875. /**
  26876. * Returns a normalized vector (Vector3) orthogonal to the ground
  26877. * at the ground coordinates (x, z) expressed in the World system.
  26878. * @param x x coordinate
  26879. * @param z z coordinate
  26880. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26881. */
  26882. getNormalAtCoordinates(x: number, z: number): Vector3;
  26883. /**
  26884. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26885. * at the ground coordinates (x, z) expressed in the World system.
  26886. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26887. * @param x x coordinate
  26888. * @param z z coordinate
  26889. * @param ref vector to store the result
  26890. * @returns the GroundMesh.
  26891. */
  26892. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26893. /**
  26894. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26895. * if the ground has been updated.
  26896. * This can be used in the render loop.
  26897. * @returns the GroundMesh.
  26898. */
  26899. updateCoordinateHeights(): GroundMesh;
  26900. private _getFacetAt;
  26901. private _initHeightQuads;
  26902. private _computeHeightQuads;
  26903. /**
  26904. * Serializes this ground mesh
  26905. * @param serializationObject object to write serialization to
  26906. */
  26907. serialize(serializationObject: any): void;
  26908. /**
  26909. * Parses a serialized ground mesh
  26910. * @param parsedMesh the serialized mesh
  26911. * @param scene the scene to create the ground mesh in
  26912. * @returns the created ground mesh
  26913. */
  26914. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26915. }
  26916. }
  26917. declare module BABYLON {
  26918. /**
  26919. * Interface for Physics-Joint data
  26920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26921. */
  26922. export interface PhysicsJointData {
  26923. /**
  26924. * The main pivot of the joint
  26925. */
  26926. mainPivot?: Vector3;
  26927. /**
  26928. * The connected pivot of the joint
  26929. */
  26930. connectedPivot?: Vector3;
  26931. /**
  26932. * The main axis of the joint
  26933. */
  26934. mainAxis?: Vector3;
  26935. /**
  26936. * The connected axis of the joint
  26937. */
  26938. connectedAxis?: Vector3;
  26939. /**
  26940. * The collision of the joint
  26941. */
  26942. collision?: boolean;
  26943. /**
  26944. * Native Oimo/Cannon/Energy data
  26945. */
  26946. nativeParams?: any;
  26947. }
  26948. /**
  26949. * This is a holder class for the physics joint created by the physics plugin
  26950. * It holds a set of functions to control the underlying joint
  26951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26952. */
  26953. export class PhysicsJoint {
  26954. /**
  26955. * The type of the physics joint
  26956. */
  26957. type: number;
  26958. /**
  26959. * The data for the physics joint
  26960. */
  26961. jointData: PhysicsJointData;
  26962. private _physicsJoint;
  26963. protected _physicsPlugin: IPhysicsEnginePlugin;
  26964. /**
  26965. * Initializes the physics joint
  26966. * @param type The type of the physics joint
  26967. * @param jointData The data for the physics joint
  26968. */
  26969. constructor(
  26970. /**
  26971. * The type of the physics joint
  26972. */
  26973. type: number,
  26974. /**
  26975. * The data for the physics joint
  26976. */
  26977. jointData: PhysicsJointData);
  26978. /**
  26979. * Gets the physics joint
  26980. */
  26981. get physicsJoint(): any;
  26982. /**
  26983. * Sets the physics joint
  26984. */
  26985. set physicsJoint(newJoint: any);
  26986. /**
  26987. * Sets the physics plugin
  26988. */
  26989. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26990. /**
  26991. * Execute a function that is physics-plugin specific.
  26992. * @param {Function} func the function that will be executed.
  26993. * It accepts two parameters: the physics world and the physics joint
  26994. */
  26995. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26996. /**
  26997. * Distance-Joint type
  26998. */
  26999. static DistanceJoint: number;
  27000. /**
  27001. * Hinge-Joint type
  27002. */
  27003. static HingeJoint: number;
  27004. /**
  27005. * Ball-and-Socket joint type
  27006. */
  27007. static BallAndSocketJoint: number;
  27008. /**
  27009. * Wheel-Joint type
  27010. */
  27011. static WheelJoint: number;
  27012. /**
  27013. * Slider-Joint type
  27014. */
  27015. static SliderJoint: number;
  27016. /**
  27017. * Prismatic-Joint type
  27018. */
  27019. static PrismaticJoint: number;
  27020. /**
  27021. * Universal-Joint type
  27022. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27023. */
  27024. static UniversalJoint: number;
  27025. /**
  27026. * Hinge-Joint 2 type
  27027. */
  27028. static Hinge2Joint: number;
  27029. /**
  27030. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27031. */
  27032. static PointToPointJoint: number;
  27033. /**
  27034. * Spring-Joint type
  27035. */
  27036. static SpringJoint: number;
  27037. /**
  27038. * Lock-Joint type
  27039. */
  27040. static LockJoint: number;
  27041. }
  27042. /**
  27043. * A class representing a physics distance joint
  27044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27045. */
  27046. export class DistanceJoint extends PhysicsJoint {
  27047. /**
  27048. *
  27049. * @param jointData The data for the Distance-Joint
  27050. */
  27051. constructor(jointData: DistanceJointData);
  27052. /**
  27053. * Update the predefined distance.
  27054. * @param maxDistance The maximum preferred distance
  27055. * @param minDistance The minimum preferred distance
  27056. */
  27057. updateDistance(maxDistance: number, minDistance?: number): void;
  27058. }
  27059. /**
  27060. * Represents a Motor-Enabled Joint
  27061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27062. */
  27063. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27064. /**
  27065. * Initializes the Motor-Enabled Joint
  27066. * @param type The type of the joint
  27067. * @param jointData The physica joint data for the joint
  27068. */
  27069. constructor(type: number, jointData: PhysicsJointData);
  27070. /**
  27071. * Set the motor values.
  27072. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27073. * @param force the force to apply
  27074. * @param maxForce max force for this motor.
  27075. */
  27076. setMotor(force?: number, maxForce?: number): void;
  27077. /**
  27078. * Set the motor's limits.
  27079. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27080. * @param upperLimit The upper limit of the motor
  27081. * @param lowerLimit The lower limit of the motor
  27082. */
  27083. setLimit(upperLimit: number, lowerLimit?: number): void;
  27084. }
  27085. /**
  27086. * This class represents a single physics Hinge-Joint
  27087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27088. */
  27089. export class HingeJoint extends MotorEnabledJoint {
  27090. /**
  27091. * Initializes the Hinge-Joint
  27092. * @param jointData The joint data for the Hinge-Joint
  27093. */
  27094. constructor(jointData: PhysicsJointData);
  27095. /**
  27096. * Set the motor values.
  27097. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27098. * @param {number} force the force to apply
  27099. * @param {number} maxForce max force for this motor.
  27100. */
  27101. setMotor(force?: number, maxForce?: number): void;
  27102. /**
  27103. * Set the motor's limits.
  27104. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27105. * @param upperLimit The upper limit of the motor
  27106. * @param lowerLimit The lower limit of the motor
  27107. */
  27108. setLimit(upperLimit: number, lowerLimit?: number): void;
  27109. }
  27110. /**
  27111. * This class represents a dual hinge physics joint (same as wheel joint)
  27112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27113. */
  27114. export class Hinge2Joint extends MotorEnabledJoint {
  27115. /**
  27116. * Initializes the Hinge2-Joint
  27117. * @param jointData The joint data for the Hinge2-Joint
  27118. */
  27119. constructor(jointData: PhysicsJointData);
  27120. /**
  27121. * Set the motor values.
  27122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27123. * @param {number} targetSpeed the speed the motor is to reach
  27124. * @param {number} maxForce max force for this motor.
  27125. * @param {motorIndex} the motor's index, 0 or 1.
  27126. */
  27127. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27128. /**
  27129. * Set the motor limits.
  27130. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27131. * @param {number} upperLimit the upper limit
  27132. * @param {number} lowerLimit lower limit
  27133. * @param {motorIndex} the motor's index, 0 or 1.
  27134. */
  27135. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27136. }
  27137. /**
  27138. * Interface for a motor enabled joint
  27139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27140. */
  27141. export interface IMotorEnabledJoint {
  27142. /**
  27143. * Physics joint
  27144. */
  27145. physicsJoint: any;
  27146. /**
  27147. * Sets the motor of the motor-enabled joint
  27148. * @param force The force of the motor
  27149. * @param maxForce The maximum force of the motor
  27150. * @param motorIndex The index of the motor
  27151. */
  27152. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27153. /**
  27154. * Sets the limit of the motor
  27155. * @param upperLimit The upper limit of the motor
  27156. * @param lowerLimit The lower limit of the motor
  27157. * @param motorIndex The index of the motor
  27158. */
  27159. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27160. }
  27161. /**
  27162. * Joint data for a Distance-Joint
  27163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27164. */
  27165. export interface DistanceJointData extends PhysicsJointData {
  27166. /**
  27167. * Max distance the 2 joint objects can be apart
  27168. */
  27169. maxDistance: number;
  27170. }
  27171. /**
  27172. * Joint data from a spring joint
  27173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27174. */
  27175. export interface SpringJointData extends PhysicsJointData {
  27176. /**
  27177. * Length of the spring
  27178. */
  27179. length: number;
  27180. /**
  27181. * Stiffness of the spring
  27182. */
  27183. stiffness: number;
  27184. /**
  27185. * Damping of the spring
  27186. */
  27187. damping: number;
  27188. /** this callback will be called when applying the force to the impostors. */
  27189. forceApplicationCallback: () => void;
  27190. }
  27191. }
  27192. declare module BABYLON {
  27193. /**
  27194. * Holds the data for the raycast result
  27195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27196. */
  27197. export class PhysicsRaycastResult {
  27198. private _hasHit;
  27199. private _hitDistance;
  27200. private _hitNormalWorld;
  27201. private _hitPointWorld;
  27202. private _rayFromWorld;
  27203. private _rayToWorld;
  27204. /**
  27205. * Gets if there was a hit
  27206. */
  27207. get hasHit(): boolean;
  27208. /**
  27209. * Gets the distance from the hit
  27210. */
  27211. get hitDistance(): number;
  27212. /**
  27213. * Gets the hit normal/direction in the world
  27214. */
  27215. get hitNormalWorld(): Vector3;
  27216. /**
  27217. * Gets the hit point in the world
  27218. */
  27219. get hitPointWorld(): Vector3;
  27220. /**
  27221. * Gets the ray "start point" of the ray in the world
  27222. */
  27223. get rayFromWorld(): Vector3;
  27224. /**
  27225. * Gets the ray "end point" of the ray in the world
  27226. */
  27227. get rayToWorld(): Vector3;
  27228. /**
  27229. * Sets the hit data (normal & point in world space)
  27230. * @param hitNormalWorld defines the normal in world space
  27231. * @param hitPointWorld defines the point in world space
  27232. */
  27233. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27234. /**
  27235. * Sets the distance from the start point to the hit point
  27236. * @param distance
  27237. */
  27238. setHitDistance(distance: number): void;
  27239. /**
  27240. * Calculates the distance manually
  27241. */
  27242. calculateHitDistance(): void;
  27243. /**
  27244. * Resets all the values to default
  27245. * @param from The from point on world space
  27246. * @param to The to point on world space
  27247. */
  27248. reset(from?: Vector3, to?: Vector3): void;
  27249. }
  27250. /**
  27251. * Interface for the size containing width and height
  27252. */
  27253. interface IXYZ {
  27254. /**
  27255. * X
  27256. */
  27257. x: number;
  27258. /**
  27259. * Y
  27260. */
  27261. y: number;
  27262. /**
  27263. * Z
  27264. */
  27265. z: number;
  27266. }
  27267. }
  27268. declare module BABYLON {
  27269. /**
  27270. * Interface used to describe a physics joint
  27271. */
  27272. export interface PhysicsImpostorJoint {
  27273. /** Defines the main impostor to which the joint is linked */
  27274. mainImpostor: PhysicsImpostor;
  27275. /** Defines the impostor that is connected to the main impostor using this joint */
  27276. connectedImpostor: PhysicsImpostor;
  27277. /** Defines the joint itself */
  27278. joint: PhysicsJoint;
  27279. }
  27280. /** @hidden */
  27281. export interface IPhysicsEnginePlugin {
  27282. world: any;
  27283. name: string;
  27284. setGravity(gravity: Vector3): void;
  27285. setTimeStep(timeStep: number): void;
  27286. getTimeStep(): number;
  27287. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27288. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27289. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27290. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27291. removePhysicsBody(impostor: PhysicsImpostor): void;
  27292. generateJoint(joint: PhysicsImpostorJoint): void;
  27293. removeJoint(joint: PhysicsImpostorJoint): void;
  27294. isSupported(): boolean;
  27295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27296. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27297. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27298. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27299. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27300. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27301. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27302. getBodyMass(impostor: PhysicsImpostor): number;
  27303. getBodyFriction(impostor: PhysicsImpostor): number;
  27304. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27305. getBodyRestitution(impostor: PhysicsImpostor): number;
  27306. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27307. getBodyPressure?(impostor: PhysicsImpostor): number;
  27308. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27309. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27310. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27311. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27312. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27313. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27314. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27315. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27316. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27317. sleepBody(impostor: PhysicsImpostor): void;
  27318. wakeUpBody(impostor: PhysicsImpostor): void;
  27319. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27320. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27321. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27323. getRadius(impostor: PhysicsImpostor): number;
  27324. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27325. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27326. dispose(): void;
  27327. }
  27328. /**
  27329. * Interface used to define a physics engine
  27330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27331. */
  27332. export interface IPhysicsEngine {
  27333. /**
  27334. * Gets the gravity vector used by the simulation
  27335. */
  27336. gravity: Vector3;
  27337. /**
  27338. * Sets the gravity vector used by the simulation
  27339. * @param gravity defines the gravity vector to use
  27340. */
  27341. setGravity(gravity: Vector3): void;
  27342. /**
  27343. * Set the time step of the physics engine.
  27344. * Default is 1/60.
  27345. * To slow it down, enter 1/600 for example.
  27346. * To speed it up, 1/30
  27347. * @param newTimeStep the new timestep to apply to this world.
  27348. */
  27349. setTimeStep(newTimeStep: number): void;
  27350. /**
  27351. * Get the time step of the physics engine.
  27352. * @returns the current time step
  27353. */
  27354. getTimeStep(): number;
  27355. /**
  27356. * Set the sub time step of the physics engine.
  27357. * Default is 0 meaning there is no sub steps
  27358. * To increase physics resolution precision, set a small value (like 1 ms)
  27359. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27360. */
  27361. setSubTimeStep(subTimeStep: number): void;
  27362. /**
  27363. * Get the sub time step of the physics engine.
  27364. * @returns the current sub time step
  27365. */
  27366. getSubTimeStep(): number;
  27367. /**
  27368. * Release all resources
  27369. */
  27370. dispose(): void;
  27371. /**
  27372. * Gets the name of the current physics plugin
  27373. * @returns the name of the plugin
  27374. */
  27375. getPhysicsPluginName(): string;
  27376. /**
  27377. * Adding a new impostor for the impostor tracking.
  27378. * This will be done by the impostor itself.
  27379. * @param impostor the impostor to add
  27380. */
  27381. addImpostor(impostor: PhysicsImpostor): void;
  27382. /**
  27383. * Remove an impostor from the engine.
  27384. * This impostor and its mesh will not longer be updated by the physics engine.
  27385. * @param impostor the impostor to remove
  27386. */
  27387. removeImpostor(impostor: PhysicsImpostor): void;
  27388. /**
  27389. * Add a joint to the physics engine
  27390. * @param mainImpostor defines the main impostor to which the joint is added.
  27391. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27392. * @param joint defines the joint that will connect both impostors.
  27393. */
  27394. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27395. /**
  27396. * Removes a joint from the simulation
  27397. * @param mainImpostor defines the impostor used with the joint
  27398. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27399. * @param joint defines the joint to remove
  27400. */
  27401. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27402. /**
  27403. * Gets the current plugin used to run the simulation
  27404. * @returns current plugin
  27405. */
  27406. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27407. /**
  27408. * Gets the list of physic impostors
  27409. * @returns an array of PhysicsImpostor
  27410. */
  27411. getImpostors(): Array<PhysicsImpostor>;
  27412. /**
  27413. * Gets the impostor for a physics enabled object
  27414. * @param object defines the object impersonated by the impostor
  27415. * @returns the PhysicsImpostor or null if not found
  27416. */
  27417. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27418. /**
  27419. * Gets the impostor for a physics body object
  27420. * @param body defines physics body used by the impostor
  27421. * @returns the PhysicsImpostor or null if not found
  27422. */
  27423. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27424. /**
  27425. * Does a raycast in the physics world
  27426. * @param from when should the ray start?
  27427. * @param to when should the ray end?
  27428. * @returns PhysicsRaycastResult
  27429. */
  27430. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27431. /**
  27432. * Called by the scene. No need to call it.
  27433. * @param delta defines the timespam between frames
  27434. */
  27435. _step(delta: number): void;
  27436. }
  27437. }
  27438. declare module BABYLON {
  27439. /**
  27440. * The interface for the physics imposter parameters
  27441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27442. */
  27443. export interface PhysicsImpostorParameters {
  27444. /**
  27445. * The mass of the physics imposter
  27446. */
  27447. mass: number;
  27448. /**
  27449. * The friction of the physics imposter
  27450. */
  27451. friction?: number;
  27452. /**
  27453. * The coefficient of restitution of the physics imposter
  27454. */
  27455. restitution?: number;
  27456. /**
  27457. * The native options of the physics imposter
  27458. */
  27459. nativeOptions?: any;
  27460. /**
  27461. * Specifies if the parent should be ignored
  27462. */
  27463. ignoreParent?: boolean;
  27464. /**
  27465. * Specifies if bi-directional transformations should be disabled
  27466. */
  27467. disableBidirectionalTransformation?: boolean;
  27468. /**
  27469. * The pressure inside the physics imposter, soft object only
  27470. */
  27471. pressure?: number;
  27472. /**
  27473. * The stiffness the physics imposter, soft object only
  27474. */
  27475. stiffness?: number;
  27476. /**
  27477. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27478. */
  27479. velocityIterations?: number;
  27480. /**
  27481. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27482. */
  27483. positionIterations?: number;
  27484. /**
  27485. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27486. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27487. * Add to fix multiple points
  27488. */
  27489. fixedPoints?: number;
  27490. /**
  27491. * The collision margin around a soft object
  27492. */
  27493. margin?: number;
  27494. /**
  27495. * The collision margin around a soft object
  27496. */
  27497. damping?: number;
  27498. /**
  27499. * The path for a rope based on an extrusion
  27500. */
  27501. path?: any;
  27502. /**
  27503. * The shape of an extrusion used for a rope based on an extrusion
  27504. */
  27505. shape?: any;
  27506. }
  27507. /**
  27508. * Interface for a physics-enabled object
  27509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27510. */
  27511. export interface IPhysicsEnabledObject {
  27512. /**
  27513. * The position of the physics-enabled object
  27514. */
  27515. position: Vector3;
  27516. /**
  27517. * The rotation of the physics-enabled object
  27518. */
  27519. rotationQuaternion: Nullable<Quaternion>;
  27520. /**
  27521. * The scale of the physics-enabled object
  27522. */
  27523. scaling: Vector3;
  27524. /**
  27525. * The rotation of the physics-enabled object
  27526. */
  27527. rotation?: Vector3;
  27528. /**
  27529. * The parent of the physics-enabled object
  27530. */
  27531. parent?: any;
  27532. /**
  27533. * The bounding info of the physics-enabled object
  27534. * @returns The bounding info of the physics-enabled object
  27535. */
  27536. getBoundingInfo(): BoundingInfo;
  27537. /**
  27538. * Computes the world matrix
  27539. * @param force Specifies if the world matrix should be computed by force
  27540. * @returns A world matrix
  27541. */
  27542. computeWorldMatrix(force: boolean): Matrix;
  27543. /**
  27544. * Gets the world matrix
  27545. * @returns A world matrix
  27546. */
  27547. getWorldMatrix?(): Matrix;
  27548. /**
  27549. * Gets the child meshes
  27550. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27551. * @returns An array of abstract meshes
  27552. */
  27553. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27554. /**
  27555. * Gets the vertex data
  27556. * @param kind The type of vertex data
  27557. * @returns A nullable array of numbers, or a float32 array
  27558. */
  27559. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27560. /**
  27561. * Gets the indices from the mesh
  27562. * @returns A nullable array of index arrays
  27563. */
  27564. getIndices?(): Nullable<IndicesArray>;
  27565. /**
  27566. * Gets the scene from the mesh
  27567. * @returns the indices array or null
  27568. */
  27569. getScene?(): Scene;
  27570. /**
  27571. * Gets the absolute position from the mesh
  27572. * @returns the absolute position
  27573. */
  27574. getAbsolutePosition(): Vector3;
  27575. /**
  27576. * Gets the absolute pivot point from the mesh
  27577. * @returns the absolute pivot point
  27578. */
  27579. getAbsolutePivotPoint(): Vector3;
  27580. /**
  27581. * Rotates the mesh
  27582. * @param axis The axis of rotation
  27583. * @param amount The amount of rotation
  27584. * @param space The space of the rotation
  27585. * @returns The rotation transform node
  27586. */
  27587. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27588. /**
  27589. * Translates the mesh
  27590. * @param axis The axis of translation
  27591. * @param distance The distance of translation
  27592. * @param space The space of the translation
  27593. * @returns The transform node
  27594. */
  27595. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27596. /**
  27597. * Sets the absolute position of the mesh
  27598. * @param absolutePosition The absolute position of the mesh
  27599. * @returns The transform node
  27600. */
  27601. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27602. /**
  27603. * Gets the class name of the mesh
  27604. * @returns The class name
  27605. */
  27606. getClassName(): string;
  27607. }
  27608. /**
  27609. * Represents a physics imposter
  27610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27611. */
  27612. export class PhysicsImpostor {
  27613. /**
  27614. * The physics-enabled object used as the physics imposter
  27615. */
  27616. object: IPhysicsEnabledObject;
  27617. /**
  27618. * The type of the physics imposter
  27619. */
  27620. type: number;
  27621. private _options;
  27622. private _scene?;
  27623. /**
  27624. * The default object size of the imposter
  27625. */
  27626. static DEFAULT_OBJECT_SIZE: Vector3;
  27627. /**
  27628. * The identity quaternion of the imposter
  27629. */
  27630. static IDENTITY_QUATERNION: Quaternion;
  27631. /** @hidden */
  27632. _pluginData: any;
  27633. private _physicsEngine;
  27634. private _physicsBody;
  27635. private _bodyUpdateRequired;
  27636. private _onBeforePhysicsStepCallbacks;
  27637. private _onAfterPhysicsStepCallbacks;
  27638. /** @hidden */
  27639. _onPhysicsCollideCallbacks: Array<{
  27640. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27641. otherImpostors: Array<PhysicsImpostor>;
  27642. }>;
  27643. private _deltaPosition;
  27644. private _deltaRotation;
  27645. private _deltaRotationConjugated;
  27646. /** @hidden */
  27647. _isFromLine: boolean;
  27648. private _parent;
  27649. private _isDisposed;
  27650. private static _tmpVecs;
  27651. private static _tmpQuat;
  27652. /**
  27653. * Specifies if the physics imposter is disposed
  27654. */
  27655. get isDisposed(): boolean;
  27656. /**
  27657. * Gets the mass of the physics imposter
  27658. */
  27659. get mass(): number;
  27660. set mass(value: number);
  27661. /**
  27662. * Gets the coefficient of friction
  27663. */
  27664. get friction(): number;
  27665. /**
  27666. * Sets the coefficient of friction
  27667. */
  27668. set friction(value: number);
  27669. /**
  27670. * Gets the coefficient of restitution
  27671. */
  27672. get restitution(): number;
  27673. /**
  27674. * Sets the coefficient of restitution
  27675. */
  27676. set restitution(value: number);
  27677. /**
  27678. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27679. */
  27680. get pressure(): number;
  27681. /**
  27682. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27683. */
  27684. set pressure(value: number);
  27685. /**
  27686. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27687. */
  27688. get stiffness(): number;
  27689. /**
  27690. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27691. */
  27692. set stiffness(value: number);
  27693. /**
  27694. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27695. */
  27696. get velocityIterations(): number;
  27697. /**
  27698. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27699. */
  27700. set velocityIterations(value: number);
  27701. /**
  27702. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27703. */
  27704. get positionIterations(): number;
  27705. /**
  27706. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27707. */
  27708. set positionIterations(value: number);
  27709. /**
  27710. * The unique id of the physics imposter
  27711. * set by the physics engine when adding this impostor to the array
  27712. */
  27713. uniqueId: number;
  27714. /**
  27715. * @hidden
  27716. */
  27717. soft: boolean;
  27718. /**
  27719. * @hidden
  27720. */
  27721. segments: number;
  27722. private _joints;
  27723. /**
  27724. * Initializes the physics imposter
  27725. * @param object The physics-enabled object used as the physics imposter
  27726. * @param type The type of the physics imposter
  27727. * @param _options The options for the physics imposter
  27728. * @param _scene The Babylon scene
  27729. */
  27730. constructor(
  27731. /**
  27732. * The physics-enabled object used as the physics imposter
  27733. */
  27734. object: IPhysicsEnabledObject,
  27735. /**
  27736. * The type of the physics imposter
  27737. */
  27738. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27739. /**
  27740. * This function will completly initialize this impostor.
  27741. * It will create a new body - but only if this mesh has no parent.
  27742. * If it has, this impostor will not be used other than to define the impostor
  27743. * of the child mesh.
  27744. * @hidden
  27745. */
  27746. _init(): void;
  27747. private _getPhysicsParent;
  27748. /**
  27749. * Should a new body be generated.
  27750. * @returns boolean specifying if body initialization is required
  27751. */
  27752. isBodyInitRequired(): boolean;
  27753. /**
  27754. * Sets the updated scaling
  27755. * @param updated Specifies if the scaling is updated
  27756. */
  27757. setScalingUpdated(): void;
  27758. /**
  27759. * Force a regeneration of this or the parent's impostor's body.
  27760. * Use under cautious - This will remove all joints already implemented.
  27761. */
  27762. forceUpdate(): void;
  27763. /**
  27764. * Gets the body that holds this impostor. Either its own, or its parent.
  27765. */
  27766. get physicsBody(): any;
  27767. /**
  27768. * Get the parent of the physics imposter
  27769. * @returns Physics imposter or null
  27770. */
  27771. get parent(): Nullable<PhysicsImpostor>;
  27772. /**
  27773. * Sets the parent of the physics imposter
  27774. */
  27775. set parent(value: Nullable<PhysicsImpostor>);
  27776. /**
  27777. * Set the physics body. Used mainly by the physics engine/plugin
  27778. */
  27779. set physicsBody(physicsBody: any);
  27780. /**
  27781. * Resets the update flags
  27782. */
  27783. resetUpdateFlags(): void;
  27784. /**
  27785. * Gets the object extend size
  27786. * @returns the object extend size
  27787. */
  27788. getObjectExtendSize(): Vector3;
  27789. /**
  27790. * Gets the object center
  27791. * @returns The object center
  27792. */
  27793. getObjectCenter(): Vector3;
  27794. /**
  27795. * Get a specific parameter from the options parameters
  27796. * @param paramName The object parameter name
  27797. * @returns The object parameter
  27798. */
  27799. getParam(paramName: string): any;
  27800. /**
  27801. * Sets a specific parameter in the options given to the physics plugin
  27802. * @param paramName The parameter name
  27803. * @param value The value of the parameter
  27804. */
  27805. setParam(paramName: string, value: number): void;
  27806. /**
  27807. * Specifically change the body's mass option. Won't recreate the physics body object
  27808. * @param mass The mass of the physics imposter
  27809. */
  27810. setMass(mass: number): void;
  27811. /**
  27812. * Gets the linear velocity
  27813. * @returns linear velocity or null
  27814. */
  27815. getLinearVelocity(): Nullable<Vector3>;
  27816. /**
  27817. * Sets the linear velocity
  27818. * @param velocity linear velocity or null
  27819. */
  27820. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27821. /**
  27822. * Gets the angular velocity
  27823. * @returns angular velocity or null
  27824. */
  27825. getAngularVelocity(): Nullable<Vector3>;
  27826. /**
  27827. * Sets the angular velocity
  27828. * @param velocity The velocity or null
  27829. */
  27830. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27831. /**
  27832. * Execute a function with the physics plugin native code
  27833. * Provide a function the will have two variables - the world object and the physics body object
  27834. * @param func The function to execute with the physics plugin native code
  27835. */
  27836. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27837. /**
  27838. * Register a function that will be executed before the physics world is stepping forward
  27839. * @param func The function to execute before the physics world is stepped forward
  27840. */
  27841. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27842. /**
  27843. * Unregister a function that will be executed before the physics world is stepping forward
  27844. * @param func The function to execute before the physics world is stepped forward
  27845. */
  27846. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27847. /**
  27848. * Register a function that will be executed after the physics step
  27849. * @param func The function to execute after physics step
  27850. */
  27851. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27852. /**
  27853. * Unregisters a function that will be executed after the physics step
  27854. * @param func The function to execute after physics step
  27855. */
  27856. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27857. /**
  27858. * register a function that will be executed when this impostor collides against a different body
  27859. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27860. * @param func Callback that is executed on collision
  27861. */
  27862. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27863. /**
  27864. * Unregisters the physics imposter on contact
  27865. * @param collideAgainst The physics object to collide against
  27866. * @param func Callback to execute on collision
  27867. */
  27868. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27869. private _tmpQuat;
  27870. private _tmpQuat2;
  27871. /**
  27872. * Get the parent rotation
  27873. * @returns The parent rotation
  27874. */
  27875. getParentsRotation(): Quaternion;
  27876. /**
  27877. * this function is executed by the physics engine.
  27878. */
  27879. beforeStep: () => void;
  27880. /**
  27881. * this function is executed by the physics engine
  27882. */
  27883. afterStep: () => void;
  27884. /**
  27885. * Legacy collision detection event support
  27886. */
  27887. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27888. /**
  27889. * event and body object due to cannon's event-based architecture.
  27890. */
  27891. onCollide: (e: {
  27892. body: any;
  27893. }) => void;
  27894. /**
  27895. * Apply a force
  27896. * @param force The force to apply
  27897. * @param contactPoint The contact point for the force
  27898. * @returns The physics imposter
  27899. */
  27900. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27901. /**
  27902. * Apply an impulse
  27903. * @param force The impulse force
  27904. * @param contactPoint The contact point for the impulse force
  27905. * @returns The physics imposter
  27906. */
  27907. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27908. /**
  27909. * A help function to create a joint
  27910. * @param otherImpostor A physics imposter used to create a joint
  27911. * @param jointType The type of joint
  27912. * @param jointData The data for the joint
  27913. * @returns The physics imposter
  27914. */
  27915. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27916. /**
  27917. * Add a joint to this impostor with a different impostor
  27918. * @param otherImpostor A physics imposter used to add a joint
  27919. * @param joint The joint to add
  27920. * @returns The physics imposter
  27921. */
  27922. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27923. /**
  27924. * Add an anchor to a cloth impostor
  27925. * @param otherImpostor rigid impostor to anchor to
  27926. * @param width ratio across width from 0 to 1
  27927. * @param height ratio up height from 0 to 1
  27928. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27929. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27930. * @returns impostor the soft imposter
  27931. */
  27932. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27933. /**
  27934. * Add a hook to a rope impostor
  27935. * @param otherImpostor rigid impostor to anchor to
  27936. * @param length ratio across rope from 0 to 1
  27937. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27938. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27939. * @returns impostor the rope imposter
  27940. */
  27941. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27942. /**
  27943. * Will keep this body still, in a sleep mode.
  27944. * @returns the physics imposter
  27945. */
  27946. sleep(): PhysicsImpostor;
  27947. /**
  27948. * Wake the body up.
  27949. * @returns The physics imposter
  27950. */
  27951. wakeUp(): PhysicsImpostor;
  27952. /**
  27953. * Clones the physics imposter
  27954. * @param newObject The physics imposter clones to this physics-enabled object
  27955. * @returns A nullable physics imposter
  27956. */
  27957. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27958. /**
  27959. * Disposes the physics imposter
  27960. */
  27961. dispose(): void;
  27962. /**
  27963. * Sets the delta position
  27964. * @param position The delta position amount
  27965. */
  27966. setDeltaPosition(position: Vector3): void;
  27967. /**
  27968. * Sets the delta rotation
  27969. * @param rotation The delta rotation amount
  27970. */
  27971. setDeltaRotation(rotation: Quaternion): void;
  27972. /**
  27973. * Gets the box size of the physics imposter and stores the result in the input parameter
  27974. * @param result Stores the box size
  27975. * @returns The physics imposter
  27976. */
  27977. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27978. /**
  27979. * Gets the radius of the physics imposter
  27980. * @returns Radius of the physics imposter
  27981. */
  27982. getRadius(): number;
  27983. /**
  27984. * Sync a bone with this impostor
  27985. * @param bone The bone to sync to the impostor.
  27986. * @param boneMesh The mesh that the bone is influencing.
  27987. * @param jointPivot The pivot of the joint / bone in local space.
  27988. * @param distToJoint Optional distance from the impostor to the joint.
  27989. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27990. */
  27991. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27992. /**
  27993. * Sync impostor to a bone
  27994. * @param bone The bone that the impostor will be synced to.
  27995. * @param boneMesh The mesh that the bone is influencing.
  27996. * @param jointPivot The pivot of the joint / bone in local space.
  27997. * @param distToJoint Optional distance from the impostor to the joint.
  27998. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27999. * @param boneAxis Optional vector3 axis the bone is aligned with
  28000. */
  28001. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28002. /**
  28003. * No-Imposter type
  28004. */
  28005. static NoImpostor: number;
  28006. /**
  28007. * Sphere-Imposter type
  28008. */
  28009. static SphereImpostor: number;
  28010. /**
  28011. * Box-Imposter type
  28012. */
  28013. static BoxImpostor: number;
  28014. /**
  28015. * Plane-Imposter type
  28016. */
  28017. static PlaneImpostor: number;
  28018. /**
  28019. * Mesh-imposter type
  28020. */
  28021. static MeshImpostor: number;
  28022. /**
  28023. * Capsule-Impostor type (Ammo.js plugin only)
  28024. */
  28025. static CapsuleImpostor: number;
  28026. /**
  28027. * Cylinder-Imposter type
  28028. */
  28029. static CylinderImpostor: number;
  28030. /**
  28031. * Particle-Imposter type
  28032. */
  28033. static ParticleImpostor: number;
  28034. /**
  28035. * Heightmap-Imposter type
  28036. */
  28037. static HeightmapImpostor: number;
  28038. /**
  28039. * ConvexHull-Impostor type (Ammo.js plugin only)
  28040. */
  28041. static ConvexHullImpostor: number;
  28042. /**
  28043. * Custom-Imposter type (Ammo.js plugin only)
  28044. */
  28045. static CustomImpostor: number;
  28046. /**
  28047. * Rope-Imposter type
  28048. */
  28049. static RopeImpostor: number;
  28050. /**
  28051. * Cloth-Imposter type
  28052. */
  28053. static ClothImpostor: number;
  28054. /**
  28055. * Softbody-Imposter type
  28056. */
  28057. static SoftbodyImpostor: number;
  28058. }
  28059. }
  28060. declare module BABYLON {
  28061. /**
  28062. * @hidden
  28063. **/
  28064. export class _CreationDataStorage {
  28065. closePath?: boolean;
  28066. closeArray?: boolean;
  28067. idx: number[];
  28068. dashSize: number;
  28069. gapSize: number;
  28070. path3D: Path3D;
  28071. pathArray: Vector3[][];
  28072. arc: number;
  28073. radius: number;
  28074. cap: number;
  28075. tessellation: number;
  28076. }
  28077. /**
  28078. * @hidden
  28079. **/
  28080. class _InstanceDataStorage {
  28081. visibleInstances: any;
  28082. batchCache: _InstancesBatch;
  28083. instancesBufferSize: number;
  28084. instancesBuffer: Nullable<Buffer>;
  28085. instancesData: Float32Array;
  28086. overridenInstanceCount: number;
  28087. isFrozen: boolean;
  28088. previousBatch: Nullable<_InstancesBatch>;
  28089. hardwareInstancedRendering: boolean;
  28090. sideOrientation: number;
  28091. manualUpdate: boolean;
  28092. }
  28093. /**
  28094. * @hidden
  28095. **/
  28096. export class _InstancesBatch {
  28097. mustReturn: boolean;
  28098. visibleInstances: Nullable<InstancedMesh[]>[];
  28099. renderSelf: boolean[];
  28100. hardwareInstancedRendering: boolean[];
  28101. }
  28102. /**
  28103. * @hidden
  28104. **/
  28105. class _ThinInstanceDataStorage {
  28106. instancesCount: number;
  28107. matrixBuffer: Nullable<Buffer>;
  28108. matrixBufferSize: number;
  28109. matrixData: Nullable<Float32Array>;
  28110. boundingVectors: Array<Vector3>;
  28111. worldMatrices: Nullable<Matrix[]>;
  28112. }
  28113. /**
  28114. * Class used to represent renderable models
  28115. */
  28116. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28117. /**
  28118. * Mesh side orientation : usually the external or front surface
  28119. */
  28120. static readonly FRONTSIDE: number;
  28121. /**
  28122. * Mesh side orientation : usually the internal or back surface
  28123. */
  28124. static readonly BACKSIDE: number;
  28125. /**
  28126. * Mesh side orientation : both internal and external or front and back surfaces
  28127. */
  28128. static readonly DOUBLESIDE: number;
  28129. /**
  28130. * Mesh side orientation : by default, `FRONTSIDE`
  28131. */
  28132. static readonly DEFAULTSIDE: number;
  28133. /**
  28134. * Mesh cap setting : no cap
  28135. */
  28136. static readonly NO_CAP: number;
  28137. /**
  28138. * Mesh cap setting : one cap at the beginning of the mesh
  28139. */
  28140. static readonly CAP_START: number;
  28141. /**
  28142. * Mesh cap setting : one cap at the end of the mesh
  28143. */
  28144. static readonly CAP_END: number;
  28145. /**
  28146. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28147. */
  28148. static readonly CAP_ALL: number;
  28149. /**
  28150. * Mesh pattern setting : no flip or rotate
  28151. */
  28152. static readonly NO_FLIP: number;
  28153. /**
  28154. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28155. */
  28156. static readonly FLIP_TILE: number;
  28157. /**
  28158. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28159. */
  28160. static readonly ROTATE_TILE: number;
  28161. /**
  28162. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28163. */
  28164. static readonly FLIP_ROW: number;
  28165. /**
  28166. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28167. */
  28168. static readonly ROTATE_ROW: number;
  28169. /**
  28170. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28171. */
  28172. static readonly FLIP_N_ROTATE_TILE: number;
  28173. /**
  28174. * Mesh pattern setting : rotate pattern and rotate
  28175. */
  28176. static readonly FLIP_N_ROTATE_ROW: number;
  28177. /**
  28178. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28179. */
  28180. static readonly CENTER: number;
  28181. /**
  28182. * Mesh tile positioning : part tiles on left
  28183. */
  28184. static readonly LEFT: number;
  28185. /**
  28186. * Mesh tile positioning : part tiles on right
  28187. */
  28188. static readonly RIGHT: number;
  28189. /**
  28190. * Mesh tile positioning : part tiles on top
  28191. */
  28192. static readonly TOP: number;
  28193. /**
  28194. * Mesh tile positioning : part tiles on bottom
  28195. */
  28196. static readonly BOTTOM: number;
  28197. /**
  28198. * Gets the default side orientation.
  28199. * @param orientation the orientation to value to attempt to get
  28200. * @returns the default orientation
  28201. * @hidden
  28202. */
  28203. static _GetDefaultSideOrientation(orientation?: number): number;
  28204. private _internalMeshDataInfo;
  28205. get computeBonesUsingShaders(): boolean;
  28206. set computeBonesUsingShaders(value: boolean);
  28207. /**
  28208. * An event triggered before rendering the mesh
  28209. */
  28210. get onBeforeRenderObservable(): Observable<Mesh>;
  28211. /**
  28212. * An event triggered before binding the mesh
  28213. */
  28214. get onBeforeBindObservable(): Observable<Mesh>;
  28215. /**
  28216. * An event triggered after rendering the mesh
  28217. */
  28218. get onAfterRenderObservable(): Observable<Mesh>;
  28219. /**
  28220. * An event triggered before drawing the mesh
  28221. */
  28222. get onBeforeDrawObservable(): Observable<Mesh>;
  28223. private _onBeforeDrawObserver;
  28224. /**
  28225. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28226. */
  28227. set onBeforeDraw(callback: () => void);
  28228. get hasInstances(): boolean;
  28229. get hasThinInstances(): boolean;
  28230. /**
  28231. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28232. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28233. */
  28234. delayLoadState: number;
  28235. /**
  28236. * Gets the list of instances created from this mesh
  28237. * it is not supposed to be modified manually.
  28238. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28239. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28240. */
  28241. instances: InstancedMesh[];
  28242. /**
  28243. * Gets the file containing delay loading data for this mesh
  28244. */
  28245. delayLoadingFile: string;
  28246. /** @hidden */
  28247. _binaryInfo: any;
  28248. /**
  28249. * User defined function used to change how LOD level selection is done
  28250. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28251. */
  28252. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28253. /**
  28254. * Gets or sets the morph target manager
  28255. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28256. */
  28257. get morphTargetManager(): Nullable<MorphTargetManager>;
  28258. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28259. /** @hidden */
  28260. _creationDataStorage: Nullable<_CreationDataStorage>;
  28261. /** @hidden */
  28262. _geometry: Nullable<Geometry>;
  28263. /** @hidden */
  28264. _delayInfo: Array<string>;
  28265. /** @hidden */
  28266. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28267. /** @hidden */
  28268. _instanceDataStorage: _InstanceDataStorage;
  28269. /** @hidden */
  28270. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28271. private _effectiveMaterial;
  28272. /** @hidden */
  28273. _shouldGenerateFlatShading: boolean;
  28274. /** @hidden */
  28275. _originalBuilderSideOrientation: number;
  28276. /**
  28277. * Use this property to change the original side orientation defined at construction time
  28278. */
  28279. overrideMaterialSideOrientation: Nullable<number>;
  28280. /**
  28281. * Gets the source mesh (the one used to clone this one from)
  28282. */
  28283. get source(): Nullable<Mesh>;
  28284. /**
  28285. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28286. */
  28287. get isUnIndexed(): boolean;
  28288. set isUnIndexed(value: boolean);
  28289. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28290. get worldMatrixInstancedBuffer(): Float32Array;
  28291. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28292. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28293. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28294. /**
  28295. * @constructor
  28296. * @param name The value used by scene.getMeshByName() to do a lookup.
  28297. * @param scene The scene to add this mesh to.
  28298. * @param parent The parent of this mesh, if it has one
  28299. * @param source An optional Mesh from which geometry is shared, cloned.
  28300. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28301. * When false, achieved by calling a clone(), also passing False.
  28302. * This will make creation of children, recursive.
  28303. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28304. */
  28305. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28306. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28307. doNotInstantiate: boolean;
  28308. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28309. /**
  28310. * Gets the class name
  28311. * @returns the string "Mesh".
  28312. */
  28313. getClassName(): string;
  28314. /** @hidden */
  28315. get _isMesh(): boolean;
  28316. /**
  28317. * Returns a description of this mesh
  28318. * @param fullDetails define if full details about this mesh must be used
  28319. * @returns a descriptive string representing this mesh
  28320. */
  28321. toString(fullDetails?: boolean): string;
  28322. /** @hidden */
  28323. _unBindEffect(): void;
  28324. /**
  28325. * Gets a boolean indicating if this mesh has LOD
  28326. */
  28327. get hasLODLevels(): boolean;
  28328. /**
  28329. * Gets the list of MeshLODLevel associated with the current mesh
  28330. * @returns an array of MeshLODLevel
  28331. */
  28332. getLODLevels(): MeshLODLevel[];
  28333. private _sortLODLevels;
  28334. /**
  28335. * Add a mesh as LOD level triggered at the given distance.
  28336. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28337. * @param distance The distance from the center of the object to show this level
  28338. * @param mesh The mesh to be added as LOD level (can be null)
  28339. * @return This mesh (for chaining)
  28340. */
  28341. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28342. /**
  28343. * Returns the LOD level mesh at the passed distance or null if not found.
  28344. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28345. * @param distance The distance from the center of the object to show this level
  28346. * @returns a Mesh or `null`
  28347. */
  28348. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28349. /**
  28350. * Remove a mesh from the LOD array
  28351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28352. * @param mesh defines the mesh to be removed
  28353. * @return This mesh (for chaining)
  28354. */
  28355. removeLODLevel(mesh: Mesh): Mesh;
  28356. /**
  28357. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28358. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28359. * @param camera defines the camera to use to compute distance
  28360. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28361. * @return This mesh (for chaining)
  28362. */
  28363. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28364. /**
  28365. * Gets the mesh internal Geometry object
  28366. */
  28367. get geometry(): Nullable<Geometry>;
  28368. /**
  28369. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28370. * @returns the total number of vertices
  28371. */
  28372. getTotalVertices(): number;
  28373. /**
  28374. * Returns the content of an associated vertex buffer
  28375. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28376. * - VertexBuffer.PositionKind
  28377. * - VertexBuffer.UVKind
  28378. * - VertexBuffer.UV2Kind
  28379. * - VertexBuffer.UV3Kind
  28380. * - VertexBuffer.UV4Kind
  28381. * - VertexBuffer.UV5Kind
  28382. * - VertexBuffer.UV6Kind
  28383. * - VertexBuffer.ColorKind
  28384. * - VertexBuffer.MatricesIndicesKind
  28385. * - VertexBuffer.MatricesIndicesExtraKind
  28386. * - VertexBuffer.MatricesWeightsKind
  28387. * - VertexBuffer.MatricesWeightsExtraKind
  28388. * @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
  28389. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28390. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28391. */
  28392. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28393. /**
  28394. * Returns the mesh VertexBuffer object from the requested `kind`
  28395. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28396. * - VertexBuffer.PositionKind
  28397. * - VertexBuffer.NormalKind
  28398. * - VertexBuffer.UVKind
  28399. * - VertexBuffer.UV2Kind
  28400. * - VertexBuffer.UV3Kind
  28401. * - VertexBuffer.UV4Kind
  28402. * - VertexBuffer.UV5Kind
  28403. * - VertexBuffer.UV6Kind
  28404. * - VertexBuffer.ColorKind
  28405. * - VertexBuffer.MatricesIndicesKind
  28406. * - VertexBuffer.MatricesIndicesExtraKind
  28407. * - VertexBuffer.MatricesWeightsKind
  28408. * - VertexBuffer.MatricesWeightsExtraKind
  28409. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28410. */
  28411. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28412. /**
  28413. * Tests if a specific vertex buffer is associated with this mesh
  28414. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28415. * - VertexBuffer.PositionKind
  28416. * - VertexBuffer.NormalKind
  28417. * - VertexBuffer.UVKind
  28418. * - VertexBuffer.UV2Kind
  28419. * - VertexBuffer.UV3Kind
  28420. * - VertexBuffer.UV4Kind
  28421. * - VertexBuffer.UV5Kind
  28422. * - VertexBuffer.UV6Kind
  28423. * - VertexBuffer.ColorKind
  28424. * - VertexBuffer.MatricesIndicesKind
  28425. * - VertexBuffer.MatricesIndicesExtraKind
  28426. * - VertexBuffer.MatricesWeightsKind
  28427. * - VertexBuffer.MatricesWeightsExtraKind
  28428. * @returns a boolean
  28429. */
  28430. isVerticesDataPresent(kind: string): boolean;
  28431. /**
  28432. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28433. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28434. * - VertexBuffer.PositionKind
  28435. * - VertexBuffer.UVKind
  28436. * - VertexBuffer.UV2Kind
  28437. * - VertexBuffer.UV3Kind
  28438. * - VertexBuffer.UV4Kind
  28439. * - VertexBuffer.UV5Kind
  28440. * - VertexBuffer.UV6Kind
  28441. * - VertexBuffer.ColorKind
  28442. * - VertexBuffer.MatricesIndicesKind
  28443. * - VertexBuffer.MatricesIndicesExtraKind
  28444. * - VertexBuffer.MatricesWeightsKind
  28445. * - VertexBuffer.MatricesWeightsExtraKind
  28446. * @returns a boolean
  28447. */
  28448. isVertexBufferUpdatable(kind: string): boolean;
  28449. /**
  28450. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28451. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28452. * - VertexBuffer.PositionKind
  28453. * - VertexBuffer.NormalKind
  28454. * - VertexBuffer.UVKind
  28455. * - VertexBuffer.UV2Kind
  28456. * - VertexBuffer.UV3Kind
  28457. * - VertexBuffer.UV4Kind
  28458. * - VertexBuffer.UV5Kind
  28459. * - VertexBuffer.UV6Kind
  28460. * - VertexBuffer.ColorKind
  28461. * - VertexBuffer.MatricesIndicesKind
  28462. * - VertexBuffer.MatricesIndicesExtraKind
  28463. * - VertexBuffer.MatricesWeightsKind
  28464. * - VertexBuffer.MatricesWeightsExtraKind
  28465. * @returns an array of strings
  28466. */
  28467. getVerticesDataKinds(): string[];
  28468. /**
  28469. * Returns a positive integer : the total number of indices in this mesh geometry.
  28470. * @returns the numner of indices or zero if the mesh has no geometry.
  28471. */
  28472. getTotalIndices(): number;
  28473. /**
  28474. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28475. * @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.
  28476. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28477. * @returns the indices array or an empty array if the mesh has no geometry
  28478. */
  28479. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28480. get isBlocked(): boolean;
  28481. /**
  28482. * Determine if the current mesh is ready to be rendered
  28483. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28484. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28485. * @returns true if all associated assets are ready (material, textures, shaders)
  28486. */
  28487. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28488. /**
  28489. * 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.
  28490. */
  28491. get areNormalsFrozen(): boolean;
  28492. /**
  28493. * 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.
  28494. * @returns the current mesh
  28495. */
  28496. freezeNormals(): Mesh;
  28497. /**
  28498. * 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
  28499. * @returns the current mesh
  28500. */
  28501. unfreezeNormals(): Mesh;
  28502. /**
  28503. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28504. */
  28505. set overridenInstanceCount(count: number);
  28506. /** @hidden */
  28507. _preActivate(): Mesh;
  28508. /** @hidden */
  28509. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28510. /** @hidden */
  28511. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28512. protected _afterComputeWorldMatrix(): void;
  28513. /** @hidden */
  28514. _postActivate(): void;
  28515. /**
  28516. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28517. * This means the mesh underlying bounding box and sphere are recomputed.
  28518. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28519. * @returns the current mesh
  28520. */
  28521. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28522. /** @hidden */
  28523. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28524. /**
  28525. * This function will subdivide the mesh into multiple submeshes
  28526. * @param count defines the expected number of submeshes
  28527. */
  28528. subdivide(count: number): void;
  28529. /**
  28530. * Copy a FloatArray into a specific associated vertex buffer
  28531. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28532. * - VertexBuffer.PositionKind
  28533. * - VertexBuffer.UVKind
  28534. * - VertexBuffer.UV2Kind
  28535. * - VertexBuffer.UV3Kind
  28536. * - VertexBuffer.UV4Kind
  28537. * - VertexBuffer.UV5Kind
  28538. * - VertexBuffer.UV6Kind
  28539. * - VertexBuffer.ColorKind
  28540. * - VertexBuffer.MatricesIndicesKind
  28541. * - VertexBuffer.MatricesIndicesExtraKind
  28542. * - VertexBuffer.MatricesWeightsKind
  28543. * - VertexBuffer.MatricesWeightsExtraKind
  28544. * @param data defines the data source
  28545. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28546. * @param stride defines the data stride size (can be null)
  28547. * @returns the current mesh
  28548. */
  28549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28550. /**
  28551. * Delete a vertex buffer associated with this mesh
  28552. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28553. * - VertexBuffer.PositionKind
  28554. * - VertexBuffer.UVKind
  28555. * - VertexBuffer.UV2Kind
  28556. * - VertexBuffer.UV3Kind
  28557. * - VertexBuffer.UV4Kind
  28558. * - VertexBuffer.UV5Kind
  28559. * - VertexBuffer.UV6Kind
  28560. * - VertexBuffer.ColorKind
  28561. * - VertexBuffer.MatricesIndicesKind
  28562. * - VertexBuffer.MatricesIndicesExtraKind
  28563. * - VertexBuffer.MatricesWeightsKind
  28564. * - VertexBuffer.MatricesWeightsExtraKind
  28565. */
  28566. removeVerticesData(kind: string): void;
  28567. /**
  28568. * Flags an associated vertex buffer as updatable
  28569. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28570. * - VertexBuffer.PositionKind
  28571. * - VertexBuffer.UVKind
  28572. * - VertexBuffer.UV2Kind
  28573. * - VertexBuffer.UV3Kind
  28574. * - VertexBuffer.UV4Kind
  28575. * - VertexBuffer.UV5Kind
  28576. * - VertexBuffer.UV6Kind
  28577. * - VertexBuffer.ColorKind
  28578. * - VertexBuffer.MatricesIndicesKind
  28579. * - VertexBuffer.MatricesIndicesExtraKind
  28580. * - VertexBuffer.MatricesWeightsKind
  28581. * - VertexBuffer.MatricesWeightsExtraKind
  28582. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28583. */
  28584. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28585. /**
  28586. * Sets the mesh global Vertex Buffer
  28587. * @param buffer defines the buffer to use
  28588. * @returns the current mesh
  28589. */
  28590. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28591. /**
  28592. * Update a specific associated vertex buffer
  28593. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28594. * - VertexBuffer.PositionKind
  28595. * - VertexBuffer.UVKind
  28596. * - VertexBuffer.UV2Kind
  28597. * - VertexBuffer.UV3Kind
  28598. * - VertexBuffer.UV4Kind
  28599. * - VertexBuffer.UV5Kind
  28600. * - VertexBuffer.UV6Kind
  28601. * - VertexBuffer.ColorKind
  28602. * - VertexBuffer.MatricesIndicesKind
  28603. * - VertexBuffer.MatricesIndicesExtraKind
  28604. * - VertexBuffer.MatricesWeightsKind
  28605. * - VertexBuffer.MatricesWeightsExtraKind
  28606. * @param data defines the data source
  28607. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28608. * @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)
  28609. * @returns the current mesh
  28610. */
  28611. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28612. /**
  28613. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28614. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28615. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28616. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28617. * @returns the current mesh
  28618. */
  28619. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28620. /**
  28621. * Creates a un-shared specific occurence of the geometry for the mesh.
  28622. * @returns the current mesh
  28623. */
  28624. makeGeometryUnique(): Mesh;
  28625. /**
  28626. * Set the index buffer of this mesh
  28627. * @param indices defines the source data
  28628. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28629. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28630. * @returns the current mesh
  28631. */
  28632. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28633. /**
  28634. * Update the current index buffer
  28635. * @param indices defines the source data
  28636. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28637. * @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)
  28638. * @returns the current mesh
  28639. */
  28640. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28641. /**
  28642. * Invert the geometry to move from a right handed system to a left handed one.
  28643. * @returns the current mesh
  28644. */
  28645. toLeftHanded(): Mesh;
  28646. /** @hidden */
  28647. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28648. /** @hidden */
  28649. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28650. /**
  28651. * Registers for this mesh a javascript function called just before the rendering process
  28652. * @param func defines the function to call before rendering this mesh
  28653. * @returns the current mesh
  28654. */
  28655. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28656. /**
  28657. * Disposes a previously registered javascript function called before the rendering
  28658. * @param func defines the function to remove
  28659. * @returns the current mesh
  28660. */
  28661. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28662. /**
  28663. * Registers for this mesh a javascript function called just after the rendering is complete
  28664. * @param func defines the function to call after rendering this mesh
  28665. * @returns the current mesh
  28666. */
  28667. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28668. /**
  28669. * Disposes a previously registered javascript function called after the rendering.
  28670. * @param func defines the function to remove
  28671. * @returns the current mesh
  28672. */
  28673. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28674. /** @hidden */
  28675. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28676. /** @hidden */
  28677. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28678. /** @hidden */
  28679. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28680. /** @hidden */
  28681. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28682. /** @hidden */
  28683. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28684. /** @hidden */
  28685. _rebuild(): void;
  28686. /** @hidden */
  28687. _freeze(): void;
  28688. /** @hidden */
  28689. _unFreeze(): void;
  28690. /**
  28691. * 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
  28692. * @param subMesh defines the subMesh to render
  28693. * @param enableAlphaMode defines if alpha mode can be changed
  28694. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28695. * @returns the current mesh
  28696. */
  28697. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28698. private _onBeforeDraw;
  28699. /**
  28700. * Renormalize the mesh and patch it up if there are no weights
  28701. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28702. * However in the case of zero weights then we set just a single influence to 1.
  28703. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28704. */
  28705. cleanMatrixWeights(): void;
  28706. private normalizeSkinFourWeights;
  28707. private normalizeSkinWeightsAndExtra;
  28708. /**
  28709. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28710. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28711. * the user know there was an issue with importing the mesh
  28712. * @returns a validation object with skinned, valid and report string
  28713. */
  28714. validateSkinning(): {
  28715. skinned: boolean;
  28716. valid: boolean;
  28717. report: string;
  28718. };
  28719. /** @hidden */
  28720. _checkDelayState(): Mesh;
  28721. private _queueLoad;
  28722. /**
  28723. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28724. * A mesh is in the frustum if its bounding box intersects the frustum
  28725. * @param frustumPlanes defines the frustum to test
  28726. * @returns true if the mesh is in the frustum planes
  28727. */
  28728. isInFrustum(frustumPlanes: Plane[]): boolean;
  28729. /**
  28730. * Sets the mesh material by the material or multiMaterial `id` property
  28731. * @param id is a string identifying the material or the multiMaterial
  28732. * @returns the current mesh
  28733. */
  28734. setMaterialByID(id: string): Mesh;
  28735. /**
  28736. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28737. * @returns an array of IAnimatable
  28738. */
  28739. getAnimatables(): IAnimatable[];
  28740. /**
  28741. * Modifies the mesh geometry according to the passed transformation matrix.
  28742. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28743. * The mesh normals are modified using the same transformation.
  28744. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28745. * @param transform defines the transform matrix to use
  28746. * @see https://doc.babylonjs.com/resources/baking_transformations
  28747. * @returns the current mesh
  28748. */
  28749. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28750. /**
  28751. * Modifies the mesh geometry according to its own current World Matrix.
  28752. * The mesh World Matrix is then reset.
  28753. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28754. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28755. * @see https://doc.babylonjs.com/resources/baking_transformations
  28756. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28757. * @returns the current mesh
  28758. */
  28759. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28760. /** @hidden */
  28761. get _positions(): Nullable<Vector3[]>;
  28762. /** @hidden */
  28763. _resetPointsArrayCache(): Mesh;
  28764. /** @hidden */
  28765. _generatePointsArray(): boolean;
  28766. /**
  28767. * Returns a new Mesh object generated from the current mesh properties.
  28768. * This method must not get confused with createInstance()
  28769. * @param name is a string, the name given to the new mesh
  28770. * @param newParent can be any Node object (default `null`)
  28771. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28772. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28773. * @returns a new mesh
  28774. */
  28775. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28776. /**
  28777. * Releases resources associated with this mesh.
  28778. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28779. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28780. */
  28781. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28782. /** @hidden */
  28783. _disposeInstanceSpecificData(): void;
  28784. /** @hidden */
  28785. _disposeThinInstanceSpecificData(): void;
  28786. /**
  28787. * Modifies the mesh geometry according to a displacement map.
  28788. * 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.
  28789. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28790. * @param url is a string, the URL from the image file is to be downloaded.
  28791. * @param minHeight is the lower limit of the displacement.
  28792. * @param maxHeight is the upper limit of the displacement.
  28793. * @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.
  28794. * @param uvOffset is an optional vector2 used to offset UV.
  28795. * @param uvScale is an optional vector2 used to scale UV.
  28796. * @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.
  28797. * @returns the Mesh.
  28798. */
  28799. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28800. /**
  28801. * Modifies the mesh geometry according to a displacementMap buffer.
  28802. * 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.
  28803. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28804. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28805. * @param heightMapWidth is the width of the buffer image.
  28806. * @param heightMapHeight is the height of the buffer image.
  28807. * @param minHeight is the lower limit of the displacement.
  28808. * @param maxHeight is the upper limit of the displacement.
  28809. * @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.
  28810. * @param uvOffset is an optional vector2 used to offset UV.
  28811. * @param uvScale is an optional vector2 used to scale UV.
  28812. * @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.
  28813. * @returns the Mesh.
  28814. */
  28815. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28816. /**
  28817. * Modify the mesh to get a flat shading rendering.
  28818. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28819. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28820. * @returns current mesh
  28821. */
  28822. convertToFlatShadedMesh(): Mesh;
  28823. /**
  28824. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28825. * In other words, more vertices, no more indices and a single bigger VBO.
  28826. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28827. * @returns current mesh
  28828. */
  28829. convertToUnIndexedMesh(): Mesh;
  28830. /**
  28831. * Inverses facet orientations.
  28832. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28833. * @param flipNormals will also inverts the normals
  28834. * @returns current mesh
  28835. */
  28836. flipFaces(flipNormals?: boolean): Mesh;
  28837. /**
  28838. * Increase the number of facets and hence vertices in a mesh
  28839. * Vertex normals are interpolated from existing vertex normals
  28840. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28841. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28842. */
  28843. increaseVertices(numberPerEdge: number): void;
  28844. /**
  28845. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28846. * This will undo any application of covertToFlatShadedMesh
  28847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28848. */
  28849. forceSharedVertices(): void;
  28850. /** @hidden */
  28851. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28852. /** @hidden */
  28853. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28854. /**
  28855. * Creates a new InstancedMesh object from the mesh model.
  28856. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28857. * @param name defines the name of the new instance
  28858. * @returns a new InstancedMesh
  28859. */
  28860. createInstance(name: string): InstancedMesh;
  28861. /**
  28862. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28863. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28864. * @returns the current mesh
  28865. */
  28866. synchronizeInstances(): Mesh;
  28867. /**
  28868. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28869. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28870. * This should be used together with the simplification to avoid disappearing triangles.
  28871. * @param successCallback an optional success callback to be called after the optimization finished.
  28872. * @returns the current mesh
  28873. */
  28874. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28875. /**
  28876. * Serialize current mesh
  28877. * @param serializationObject defines the object which will receive the serialization data
  28878. */
  28879. serialize(serializationObject: any): void;
  28880. /** @hidden */
  28881. _syncGeometryWithMorphTargetManager(): void;
  28882. /** @hidden */
  28883. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28884. /**
  28885. * Returns a new Mesh object parsed from the source provided.
  28886. * @param parsedMesh is the source
  28887. * @param scene defines the hosting scene
  28888. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28889. * @returns a new Mesh
  28890. */
  28891. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28892. /**
  28893. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28894. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28895. * @param name defines the name of the mesh to create
  28896. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28897. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28898. * @param closePath creates a seam between the first and the last points of each path of the path array
  28899. * @param offset is taken in account only if the `pathArray` is containing a single path
  28900. * @param scene defines the hosting scene
  28901. * @param updatable defines if the mesh must be flagged as updatable
  28902. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28903. * @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)
  28904. * @returns a new Mesh
  28905. */
  28906. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28907. /**
  28908. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28909. * @param name defines the name of the mesh to create
  28910. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28911. * @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
  28912. * @param scene defines the hosting scene
  28913. * @param updatable defines if the mesh must be flagged as updatable
  28914. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28915. * @returns a new Mesh
  28916. */
  28917. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28918. /**
  28919. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28920. * @param name defines the name of the mesh to create
  28921. * @param size sets the size (float) of each box side (default 1)
  28922. * @param scene defines the hosting scene
  28923. * @param updatable defines if the mesh must be flagged as updatable
  28924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28925. * @returns a new Mesh
  28926. */
  28927. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28928. /**
  28929. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28930. * @param name defines the name of the mesh to create
  28931. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28932. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28933. * @param scene defines the hosting scene
  28934. * @param updatable defines if the mesh must be flagged as updatable
  28935. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28936. * @returns a new Mesh
  28937. */
  28938. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28939. /**
  28940. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28941. * @param name defines the name of the mesh to create
  28942. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28943. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28944. * @param scene defines the hosting scene
  28945. * @returns a new Mesh
  28946. */
  28947. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28948. /**
  28949. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28950. * @param name defines the name of the mesh to create
  28951. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28952. * @param diameterTop set the top cap diameter (floats, default 1)
  28953. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28954. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28955. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28956. * @param scene defines the hosting scene
  28957. * @param updatable defines if the mesh must be flagged as updatable
  28958. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28959. * @returns a new Mesh
  28960. */
  28961. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28962. /**
  28963. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28964. * @param name defines the name of the mesh to create
  28965. * @param diameter sets the diameter size (float) of the torus (default 1)
  28966. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28967. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28968. * @param scene defines the hosting scene
  28969. * @param updatable defines if the mesh must be flagged as updatable
  28970. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28971. * @returns a new Mesh
  28972. */
  28973. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28974. /**
  28975. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28976. * @param name defines the name of the mesh to create
  28977. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28978. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28979. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28980. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28981. * @param p the number of windings on X axis (positive integers, default 2)
  28982. * @param q the number of windings on Y axis (positive integers, default 3)
  28983. * @param scene defines the hosting scene
  28984. * @param updatable defines if the mesh must be flagged as updatable
  28985. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28986. * @returns a new Mesh
  28987. */
  28988. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28989. /**
  28990. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28991. * @param name defines the name of the mesh to create
  28992. * @param points is an array successive Vector3
  28993. * @param scene defines the hosting scene
  28994. * @param updatable defines if the mesh must be flagged as updatable
  28995. * @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).
  28996. * @returns a new Mesh
  28997. */
  28998. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28999. /**
  29000. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29001. * @param name defines the name of the mesh to create
  29002. * @param points is an array successive Vector3
  29003. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29004. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29005. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29006. * @param scene defines the hosting scene
  29007. * @param updatable defines if the mesh must be flagged as updatable
  29008. * @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)
  29009. * @returns a new Mesh
  29010. */
  29011. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29012. /**
  29013. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29014. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29015. * 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.
  29016. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29017. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29018. * Remember you can only change the shape positions, not their number when updating a polygon.
  29019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29020. * @param name defines the name of the mesh to create
  29021. * @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
  29022. * @param scene defines the hosting scene
  29023. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29024. * @param updatable defines if the mesh must be flagged as updatable
  29025. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29026. * @param earcutInjection can be used to inject your own earcut reference
  29027. * @returns a new Mesh
  29028. */
  29029. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29030. /**
  29031. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29033. * @param name defines the name of the mesh to create
  29034. * @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
  29035. * @param depth defines the height of extrusion
  29036. * @param scene defines the hosting scene
  29037. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29038. * @param updatable defines if the mesh must be flagged as updatable
  29039. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29040. * @param earcutInjection can be used to inject your own earcut reference
  29041. * @returns a new Mesh
  29042. */
  29043. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29044. /**
  29045. * Creates an extruded shape mesh.
  29046. * 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
  29047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29049. * @param name defines the name of the mesh to create
  29050. * @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
  29051. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29052. * @param scale is the value to scale the shape
  29053. * @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
  29054. * @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
  29055. * @param scene defines the hosting scene
  29056. * @param updatable defines if the mesh must be flagged as updatable
  29057. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29058. * @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)
  29059. * @returns a new Mesh
  29060. */
  29061. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29062. /**
  29063. * Creates an custom extruded shape mesh.
  29064. * The custom extrusion is a parametric shape.
  29065. * It has no predefined shape. Its final shape will depend on the input parameters.
  29066. * Please consider using the same method from the MeshBuilder class instead
  29067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29068. * @param name defines the name of the mesh to create
  29069. * @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
  29070. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29071. * @param scaleFunction is a custom Javascript function called on each path point
  29072. * @param rotationFunction is a custom Javascript function called on each path point
  29073. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29074. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29075. * @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
  29076. * @param scene defines the hosting scene
  29077. * @param updatable defines if the mesh must be flagged as updatable
  29078. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29079. * @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)
  29080. * @returns a new Mesh
  29081. */
  29082. 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;
  29083. /**
  29084. * Creates lathe mesh.
  29085. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29086. * Please consider using the same method from the MeshBuilder class instead
  29087. * @param name defines the name of the mesh to create
  29088. * @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
  29089. * @param radius is the radius value of the lathe
  29090. * @param tessellation is the side number of the lathe.
  29091. * @param scene defines the hosting scene
  29092. * @param updatable defines if the mesh must be flagged as updatable
  29093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29094. * @returns a new Mesh
  29095. */
  29096. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29097. /**
  29098. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29099. * @param name defines the name of the mesh to create
  29100. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29101. * @param scene defines the hosting scene
  29102. * @param updatable defines if the mesh must be flagged as updatable
  29103. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29104. * @returns a new Mesh
  29105. */
  29106. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29107. /**
  29108. * Creates a ground mesh.
  29109. * Please consider using the same method from the MeshBuilder class instead
  29110. * @param name defines the name of the mesh to create
  29111. * @param width set the width of the ground
  29112. * @param height set the height of the ground
  29113. * @param subdivisions sets the number of subdivisions per side
  29114. * @param scene defines the hosting scene
  29115. * @param updatable defines if the mesh must be flagged as updatable
  29116. * @returns a new Mesh
  29117. */
  29118. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29119. /**
  29120. * Creates a tiled ground mesh.
  29121. * Please consider using the same method from the MeshBuilder class instead
  29122. * @param name defines the name of the mesh to create
  29123. * @param xmin set the ground minimum X coordinate
  29124. * @param zmin set the ground minimum Y coordinate
  29125. * @param xmax set the ground maximum X coordinate
  29126. * @param zmax set the ground maximum Z coordinate
  29127. * @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
  29128. * @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
  29129. * @param scene defines the hosting scene
  29130. * @param updatable defines if the mesh must be flagged as updatable
  29131. * @returns a new Mesh
  29132. */
  29133. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29134. w: number;
  29135. h: number;
  29136. }, precision: {
  29137. w: number;
  29138. h: number;
  29139. }, scene: Scene, updatable?: boolean): Mesh;
  29140. /**
  29141. * Creates a ground mesh from a height map.
  29142. * Please consider using the same method from the MeshBuilder class instead
  29143. * @see https://doc.babylonjs.com/babylon101/height_map
  29144. * @param name defines the name of the mesh to create
  29145. * @param url sets the URL of the height map image resource
  29146. * @param width set the ground width size
  29147. * @param height set the ground height size
  29148. * @param subdivisions sets the number of subdivision per side
  29149. * @param minHeight is the minimum altitude on the ground
  29150. * @param maxHeight is the maximum altitude on the ground
  29151. * @param scene defines the hosting scene
  29152. * @param updatable defines if the mesh must be flagged as updatable
  29153. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29154. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29155. * @returns a new Mesh
  29156. */
  29157. 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;
  29158. /**
  29159. * Creates a tube mesh.
  29160. * The tube is a parametric shape.
  29161. * It has no predefined shape. Its final shape will depend on the input parameters.
  29162. * Please consider using the same method from the MeshBuilder class instead
  29163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29164. * @param name defines the name of the mesh to create
  29165. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29166. * @param radius sets the tube radius size
  29167. * @param tessellation is the number of sides on the tubular surface
  29168. * @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
  29169. * @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
  29170. * @param scene defines the hosting scene
  29171. * @param updatable defines if the mesh must be flagged as updatable
  29172. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29173. * @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)
  29174. * @returns a new Mesh
  29175. */
  29176. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29177. (i: number, distance: number): number;
  29178. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29179. /**
  29180. * Creates a polyhedron mesh.
  29181. * Please consider using the same method from the MeshBuilder class instead.
  29182. * * 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
  29183. * * The parameter `size` (positive float, default 1) sets the polygon size
  29184. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29185. * * 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`
  29186. * * 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
  29187. * * 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)`)
  29188. * * 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
  29189. * * 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
  29190. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29191. * * 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
  29192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29193. * @param name defines the name of the mesh to create
  29194. * @param options defines the options used to create the mesh
  29195. * @param scene defines the hosting scene
  29196. * @returns a new Mesh
  29197. */
  29198. static CreatePolyhedron(name: string, options: {
  29199. type?: number;
  29200. size?: number;
  29201. sizeX?: number;
  29202. sizeY?: number;
  29203. sizeZ?: number;
  29204. custom?: any;
  29205. faceUV?: Vector4[];
  29206. faceColors?: Color4[];
  29207. updatable?: boolean;
  29208. sideOrientation?: number;
  29209. }, scene: Scene): Mesh;
  29210. /**
  29211. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29212. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29213. * * 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`)
  29214. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29215. * * 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
  29216. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29217. * * 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
  29218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29219. * @param name defines the name of the mesh
  29220. * @param options defines the options used to create the mesh
  29221. * @param scene defines the hosting scene
  29222. * @returns a new Mesh
  29223. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29224. */
  29225. static CreateIcoSphere(name: string, options: {
  29226. radius?: number;
  29227. flat?: boolean;
  29228. subdivisions?: number;
  29229. sideOrientation?: number;
  29230. updatable?: boolean;
  29231. }, scene: Scene): Mesh;
  29232. /**
  29233. * Creates a decal mesh.
  29234. * Please consider using the same method from the MeshBuilder class instead.
  29235. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29236. * @param name defines the name of the mesh
  29237. * @param sourceMesh defines the mesh receiving the decal
  29238. * @param position sets the position of the decal in world coordinates
  29239. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29240. * @param size sets the decal scaling
  29241. * @param angle sets the angle to rotate the decal
  29242. * @returns a new Mesh
  29243. */
  29244. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29245. /**
  29246. * Prepare internal position array for software CPU skinning
  29247. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29248. */
  29249. setPositionsForCPUSkinning(): Float32Array;
  29250. /**
  29251. * Prepare internal normal array for software CPU skinning
  29252. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29253. */
  29254. setNormalsForCPUSkinning(): Float32Array;
  29255. /**
  29256. * Updates the vertex buffer by applying transformation from the bones
  29257. * @param skeleton defines the skeleton to apply to current mesh
  29258. * @returns the current mesh
  29259. */
  29260. applySkeleton(skeleton: Skeleton): Mesh;
  29261. /**
  29262. * 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
  29263. * @param meshes defines the list of meshes to scan
  29264. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29265. */
  29266. static MinMax(meshes: AbstractMesh[]): {
  29267. min: Vector3;
  29268. max: Vector3;
  29269. };
  29270. /**
  29271. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29272. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29273. * @returns a vector3
  29274. */
  29275. static Center(meshesOrMinMaxVector: {
  29276. min: Vector3;
  29277. max: Vector3;
  29278. } | AbstractMesh[]): Vector3;
  29279. /**
  29280. * Merge the array of meshes into a single mesh for performance reasons.
  29281. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29282. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29283. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29284. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29285. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29286. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29287. * @returns a new mesh
  29288. */
  29289. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29290. /** @hidden */
  29291. addInstance(instance: InstancedMesh): void;
  29292. /** @hidden */
  29293. removeInstance(instance: InstancedMesh): void;
  29294. }
  29295. }
  29296. declare module BABYLON {
  29297. /**
  29298. * This is the base class of all the camera used in the application.
  29299. * @see https://doc.babylonjs.com/features/cameras
  29300. */
  29301. export class Camera extends Node {
  29302. /** @hidden */
  29303. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29304. /**
  29305. * This is the default projection mode used by the cameras.
  29306. * It helps recreating a feeling of perspective and better appreciate depth.
  29307. * This is the best way to simulate real life cameras.
  29308. */
  29309. static readonly PERSPECTIVE_CAMERA: number;
  29310. /**
  29311. * This helps creating camera with an orthographic mode.
  29312. * 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.
  29313. */
  29314. static readonly ORTHOGRAPHIC_CAMERA: number;
  29315. /**
  29316. * This is the default FOV mode for perspective cameras.
  29317. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29318. */
  29319. static readonly FOVMODE_VERTICAL_FIXED: number;
  29320. /**
  29321. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29322. */
  29323. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29324. /**
  29325. * This specifies ther is no need for a camera rig.
  29326. * Basically only one eye is rendered corresponding to the camera.
  29327. */
  29328. static readonly RIG_MODE_NONE: number;
  29329. /**
  29330. * Simulates a camera Rig with one blue eye and one red eye.
  29331. * This can be use with 3d blue and red glasses.
  29332. */
  29333. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29334. /**
  29335. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29336. */
  29337. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29338. /**
  29339. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29340. */
  29341. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29342. /**
  29343. * Defines that both eyes of the camera will be rendered over under each other.
  29344. */
  29345. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29346. /**
  29347. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29348. */
  29349. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29350. /**
  29351. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29352. */
  29353. static readonly RIG_MODE_VR: number;
  29354. /**
  29355. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29356. */
  29357. static readonly RIG_MODE_WEBVR: number;
  29358. /**
  29359. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29360. */
  29361. static readonly RIG_MODE_CUSTOM: number;
  29362. /**
  29363. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29364. */
  29365. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29366. /**
  29367. * Define the input manager associated with the camera.
  29368. */
  29369. inputs: CameraInputsManager<Camera>;
  29370. /** @hidden */
  29371. _position: Vector3;
  29372. /**
  29373. * Define the current local position of the camera in the scene
  29374. */
  29375. get position(): Vector3;
  29376. set position(newPosition: Vector3);
  29377. /**
  29378. * The vector the camera should consider as up.
  29379. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29380. */
  29381. upVector: Vector3;
  29382. /**
  29383. * Define the current limit on the left side for an orthographic camera
  29384. * In scene unit
  29385. */
  29386. orthoLeft: Nullable<number>;
  29387. /**
  29388. * Define the current limit on the right side for an orthographic camera
  29389. * In scene unit
  29390. */
  29391. orthoRight: Nullable<number>;
  29392. /**
  29393. * Define the current limit on the bottom side for an orthographic camera
  29394. * In scene unit
  29395. */
  29396. orthoBottom: Nullable<number>;
  29397. /**
  29398. * Define the current limit on the top side for an orthographic camera
  29399. * In scene unit
  29400. */
  29401. orthoTop: Nullable<number>;
  29402. /**
  29403. * Field Of View is set in Radians. (default is 0.8)
  29404. */
  29405. fov: number;
  29406. /**
  29407. * Define the minimum distance the camera can see from.
  29408. * This is important to note that the depth buffer are not infinite and the closer it starts
  29409. * the more your scene might encounter depth fighting issue.
  29410. */
  29411. minZ: number;
  29412. /**
  29413. * Define the maximum distance the camera can see to.
  29414. * This is important to note that the depth buffer are not infinite and the further it end
  29415. * the more your scene might encounter depth fighting issue.
  29416. */
  29417. maxZ: number;
  29418. /**
  29419. * Define the default inertia of the camera.
  29420. * This helps giving a smooth feeling to the camera movement.
  29421. */
  29422. inertia: number;
  29423. /**
  29424. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29425. */
  29426. mode: number;
  29427. /**
  29428. * Define whether the camera is intermediate.
  29429. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29430. */
  29431. isIntermediate: boolean;
  29432. /**
  29433. * Define the viewport of the camera.
  29434. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29435. */
  29436. viewport: Viewport;
  29437. /**
  29438. * Restricts the camera to viewing objects with the same layerMask.
  29439. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29440. */
  29441. layerMask: number;
  29442. /**
  29443. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29444. */
  29445. fovMode: number;
  29446. /**
  29447. * Rig mode of the camera.
  29448. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29449. * This is normally controlled byt the camera themselves as internal use.
  29450. */
  29451. cameraRigMode: number;
  29452. /**
  29453. * Defines the distance between both "eyes" in case of a RIG
  29454. */
  29455. interaxialDistance: number;
  29456. /**
  29457. * Defines if stereoscopic rendering is done side by side or over under.
  29458. */
  29459. isStereoscopicSideBySide: boolean;
  29460. /**
  29461. * 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
  29462. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29463. * else in the scene. (Eg. security camera)
  29464. *
  29465. * 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)
  29466. */
  29467. customRenderTargets: RenderTargetTexture[];
  29468. /**
  29469. * When set, the camera will render to this render target instead of the default canvas
  29470. *
  29471. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29472. */
  29473. outputRenderTarget: Nullable<RenderTargetTexture>;
  29474. /**
  29475. * Observable triggered when the camera view matrix has changed.
  29476. */
  29477. onViewMatrixChangedObservable: Observable<Camera>;
  29478. /**
  29479. * Observable triggered when the camera Projection matrix has changed.
  29480. */
  29481. onProjectionMatrixChangedObservable: Observable<Camera>;
  29482. /**
  29483. * Observable triggered when the inputs have been processed.
  29484. */
  29485. onAfterCheckInputsObservable: Observable<Camera>;
  29486. /**
  29487. * Observable triggered when reset has been called and applied to the camera.
  29488. */
  29489. onRestoreStateObservable: Observable<Camera>;
  29490. /**
  29491. * Is this camera a part of a rig system?
  29492. */
  29493. isRigCamera: boolean;
  29494. /**
  29495. * If isRigCamera set to true this will be set with the parent camera.
  29496. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29497. */
  29498. rigParent?: Camera;
  29499. /** @hidden */
  29500. _cameraRigParams: any;
  29501. /** @hidden */
  29502. _rigCameras: Camera[];
  29503. /** @hidden */
  29504. _rigPostProcess: Nullable<PostProcess>;
  29505. protected _webvrViewMatrix: Matrix;
  29506. /** @hidden */
  29507. _skipRendering: boolean;
  29508. /** @hidden */
  29509. _projectionMatrix: Matrix;
  29510. /** @hidden */
  29511. _postProcesses: Nullable<PostProcess>[];
  29512. /** @hidden */
  29513. _activeMeshes: SmartArray<AbstractMesh>;
  29514. protected _globalPosition: Vector3;
  29515. /** @hidden */
  29516. _computedViewMatrix: Matrix;
  29517. private _doNotComputeProjectionMatrix;
  29518. private _transformMatrix;
  29519. private _frustumPlanes;
  29520. private _refreshFrustumPlanes;
  29521. private _storedFov;
  29522. private _stateStored;
  29523. /**
  29524. * Instantiates a new camera object.
  29525. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29526. * @see https://doc.babylonjs.com/features/cameras
  29527. * @param name Defines the name of the camera in the scene
  29528. * @param position Defines the position of the camera
  29529. * @param scene Defines the scene the camera belongs too
  29530. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29531. */
  29532. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29533. /**
  29534. * Store current camera state (fov, position, etc..)
  29535. * @returns the camera
  29536. */
  29537. storeState(): Camera;
  29538. /**
  29539. * Restores the camera state values if it has been stored. You must call storeState() first
  29540. */
  29541. protected _restoreStateValues(): boolean;
  29542. /**
  29543. * Restored camera state. You must call storeState() first.
  29544. * @returns true if restored and false otherwise
  29545. */
  29546. restoreState(): boolean;
  29547. /**
  29548. * Gets the class name of the camera.
  29549. * @returns the class name
  29550. */
  29551. getClassName(): string;
  29552. /** @hidden */
  29553. readonly _isCamera: boolean;
  29554. /**
  29555. * Gets a string representation of the camera useful for debug purpose.
  29556. * @param fullDetails Defines that a more verboe level of logging is required
  29557. * @returns the string representation
  29558. */
  29559. toString(fullDetails?: boolean): string;
  29560. /**
  29561. * Gets the current world space position of the camera.
  29562. */
  29563. get globalPosition(): Vector3;
  29564. /**
  29565. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29566. * @returns the active meshe list
  29567. */
  29568. getActiveMeshes(): SmartArray<AbstractMesh>;
  29569. /**
  29570. * Check whether a mesh is part of the current active mesh list of the camera
  29571. * @param mesh Defines the mesh to check
  29572. * @returns true if active, false otherwise
  29573. */
  29574. isActiveMesh(mesh: Mesh): boolean;
  29575. /**
  29576. * Is this camera ready to be used/rendered
  29577. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29578. * @return true if the camera is ready
  29579. */
  29580. isReady(completeCheck?: boolean): boolean;
  29581. /** @hidden */
  29582. _initCache(): void;
  29583. /** @hidden */
  29584. _updateCache(ignoreParentClass?: boolean): void;
  29585. /** @hidden */
  29586. _isSynchronized(): boolean;
  29587. /** @hidden */
  29588. _isSynchronizedViewMatrix(): boolean;
  29589. /** @hidden */
  29590. _isSynchronizedProjectionMatrix(): boolean;
  29591. /**
  29592. * Attach the input controls to a specific dom element to get the input from.
  29593. * @param element Defines the element the controls should be listened from
  29594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29595. */
  29596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29597. /**
  29598. * Detach the current controls from the specified dom element.
  29599. * @param element Defines the element to stop listening the inputs from
  29600. */
  29601. detachControl(element: HTMLElement): void;
  29602. /**
  29603. * Update the camera state according to the different inputs gathered during the frame.
  29604. */
  29605. update(): void;
  29606. /** @hidden */
  29607. _checkInputs(): void;
  29608. /** @hidden */
  29609. get rigCameras(): Camera[];
  29610. /**
  29611. * Gets the post process used by the rig cameras
  29612. */
  29613. get rigPostProcess(): Nullable<PostProcess>;
  29614. /**
  29615. * Internal, gets the first post proces.
  29616. * @returns the first post process to be run on this camera.
  29617. */
  29618. _getFirstPostProcess(): Nullable<PostProcess>;
  29619. private _cascadePostProcessesToRigCams;
  29620. /**
  29621. * Attach a post process to the camera.
  29622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29623. * @param postProcess The post process to attach to the camera
  29624. * @param insertAt The position of the post process in case several of them are in use in the scene
  29625. * @returns the position the post process has been inserted at
  29626. */
  29627. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29628. /**
  29629. * Detach a post process to the camera.
  29630. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29631. * @param postProcess The post process to detach from the camera
  29632. */
  29633. detachPostProcess(postProcess: PostProcess): void;
  29634. /**
  29635. * Gets the current world matrix of the camera
  29636. */
  29637. getWorldMatrix(): Matrix;
  29638. /** @hidden */
  29639. _getViewMatrix(): Matrix;
  29640. /**
  29641. * Gets the current view matrix of the camera.
  29642. * @param force forces the camera to recompute the matrix without looking at the cached state
  29643. * @returns the view matrix
  29644. */
  29645. getViewMatrix(force?: boolean): Matrix;
  29646. /**
  29647. * Freeze the projection matrix.
  29648. * It will prevent the cache check of the camera projection compute and can speed up perf
  29649. * if no parameter of the camera are meant to change
  29650. * @param projection Defines manually a projection if necessary
  29651. */
  29652. freezeProjectionMatrix(projection?: Matrix): void;
  29653. /**
  29654. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29655. */
  29656. unfreezeProjectionMatrix(): void;
  29657. /**
  29658. * Gets the current projection matrix of the camera.
  29659. * @param force forces the camera to recompute the matrix without looking at the cached state
  29660. * @returns the projection matrix
  29661. */
  29662. getProjectionMatrix(force?: boolean): Matrix;
  29663. /**
  29664. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29665. * @returns a Matrix
  29666. */
  29667. getTransformationMatrix(): Matrix;
  29668. private _updateFrustumPlanes;
  29669. /**
  29670. * Checks if a cullable object (mesh...) is in the camera frustum
  29671. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29672. * @param target The object to check
  29673. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29674. * @returns true if the object is in frustum otherwise false
  29675. */
  29676. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29677. /**
  29678. * Checks if a cullable object (mesh...) is in the camera frustum
  29679. * Unlike isInFrustum this cheks the full bounding box
  29680. * @param target The object to check
  29681. * @returns true if the object is in frustum otherwise false
  29682. */
  29683. isCompletelyInFrustum(target: ICullable): boolean;
  29684. /**
  29685. * Gets a ray in the forward direction from the camera.
  29686. * @param length Defines the length of the ray to create
  29687. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29688. * @param origin Defines the start point of the ray which defaults to the camera position
  29689. * @returns the forward ray
  29690. */
  29691. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29692. /**
  29693. * Gets a ray in the forward direction from the camera.
  29694. * @param refRay the ray to (re)use when setting the values
  29695. * @param length Defines the length of the ray to create
  29696. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29697. * @param origin Defines the start point of the ray which defaults to the camera position
  29698. * @returns the forward ray
  29699. */
  29700. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29701. /**
  29702. * Releases resources associated with this node.
  29703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29705. */
  29706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29707. /** @hidden */
  29708. _isLeftCamera: boolean;
  29709. /**
  29710. * Gets the left camera of a rig setup in case of Rigged Camera
  29711. */
  29712. get isLeftCamera(): boolean;
  29713. /** @hidden */
  29714. _isRightCamera: boolean;
  29715. /**
  29716. * Gets the right camera of a rig setup in case of Rigged Camera
  29717. */
  29718. get isRightCamera(): boolean;
  29719. /**
  29720. * Gets the left camera of a rig setup in case of Rigged Camera
  29721. */
  29722. get leftCamera(): Nullable<FreeCamera>;
  29723. /**
  29724. * Gets the right camera of a rig setup in case of Rigged Camera
  29725. */
  29726. get rightCamera(): Nullable<FreeCamera>;
  29727. /**
  29728. * Gets the left camera target of a rig setup in case of Rigged Camera
  29729. * @returns the target position
  29730. */
  29731. getLeftTarget(): Nullable<Vector3>;
  29732. /**
  29733. * Gets the right camera target of a rig setup in case of Rigged Camera
  29734. * @returns the target position
  29735. */
  29736. getRightTarget(): Nullable<Vector3>;
  29737. /**
  29738. * @hidden
  29739. */
  29740. setCameraRigMode(mode: number, rigParams: any): void;
  29741. /** @hidden */
  29742. static _setStereoscopicRigMode(camera: Camera): void;
  29743. /** @hidden */
  29744. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29745. /** @hidden */
  29746. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29747. /** @hidden */
  29748. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29749. /** @hidden */
  29750. _getVRProjectionMatrix(): Matrix;
  29751. protected _updateCameraRotationMatrix(): void;
  29752. protected _updateWebVRCameraRotationMatrix(): void;
  29753. /**
  29754. * This function MUST be overwritten by the different WebVR cameras available.
  29755. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29756. * @hidden
  29757. */
  29758. _getWebVRProjectionMatrix(): Matrix;
  29759. /**
  29760. * This function MUST be overwritten by the different WebVR cameras available.
  29761. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29762. * @hidden
  29763. */
  29764. _getWebVRViewMatrix(): Matrix;
  29765. /** @hidden */
  29766. setCameraRigParameter(name: string, value: any): void;
  29767. /**
  29768. * needs to be overridden by children so sub has required properties to be copied
  29769. * @hidden
  29770. */
  29771. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29772. /**
  29773. * May need to be overridden by children
  29774. * @hidden
  29775. */
  29776. _updateRigCameras(): void;
  29777. /** @hidden */
  29778. _setupInputs(): void;
  29779. /**
  29780. * Serialiaze the camera setup to a json represention
  29781. * @returns the JSON representation
  29782. */
  29783. serialize(): any;
  29784. /**
  29785. * Clones the current camera.
  29786. * @param name The cloned camera name
  29787. * @returns the cloned camera
  29788. */
  29789. clone(name: string): Camera;
  29790. /**
  29791. * Gets the direction of the camera relative to a given local axis.
  29792. * @param localAxis Defines the reference axis to provide a relative direction.
  29793. * @return the direction
  29794. */
  29795. getDirection(localAxis: Vector3): Vector3;
  29796. /**
  29797. * Returns the current camera absolute rotation
  29798. */
  29799. get absoluteRotation(): Quaternion;
  29800. /**
  29801. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29802. * @param localAxis Defines the reference axis to provide a relative direction.
  29803. * @param result Defines the vector to store the result in
  29804. */
  29805. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29806. /**
  29807. * Gets a camera constructor for a given camera type
  29808. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29809. * @param name The name of the camera the result will be able to instantiate
  29810. * @param scene The scene the result will construct the camera in
  29811. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29812. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29813. * @returns a factory method to construc the camera
  29814. */
  29815. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29816. /**
  29817. * Compute the world matrix of the camera.
  29818. * @returns the camera world matrix
  29819. */
  29820. computeWorldMatrix(): Matrix;
  29821. /**
  29822. * Parse a JSON and creates the camera from the parsed information
  29823. * @param parsedCamera The JSON to parse
  29824. * @param scene The scene to instantiate the camera in
  29825. * @returns the newly constructed camera
  29826. */
  29827. static Parse(parsedCamera: any, scene: Scene): Camera;
  29828. }
  29829. }
  29830. declare module BABYLON {
  29831. /**
  29832. * Class containing static functions to help procedurally build meshes
  29833. */
  29834. export class DiscBuilder {
  29835. /**
  29836. * Creates a plane polygonal mesh. By default, this is a disc
  29837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29838. * * 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
  29839. * * 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
  29840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29841. * * 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
  29842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29843. * @param name defines the name of the mesh
  29844. * @param options defines the options used to create the mesh
  29845. * @param scene defines the hosting scene
  29846. * @returns the plane polygonal mesh
  29847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29848. */
  29849. static CreateDisc(name: string, options: {
  29850. radius?: number;
  29851. tessellation?: number;
  29852. arc?: number;
  29853. updatable?: boolean;
  29854. sideOrientation?: number;
  29855. frontUVs?: Vector4;
  29856. backUVs?: Vector4;
  29857. }, scene?: Nullable<Scene>): Mesh;
  29858. }
  29859. }
  29860. declare module BABYLON {
  29861. /**
  29862. * Options to be used when creating a FresnelParameters.
  29863. */
  29864. export type IFresnelParametersCreationOptions = {
  29865. /**
  29866. * Define the color used on edges (grazing angle)
  29867. */
  29868. leftColor?: Color3;
  29869. /**
  29870. * Define the color used on center
  29871. */
  29872. rightColor?: Color3;
  29873. /**
  29874. * Define bias applied to computed fresnel term
  29875. */
  29876. bias?: number;
  29877. /**
  29878. * Defined the power exponent applied to fresnel term
  29879. */
  29880. power?: number;
  29881. /**
  29882. * Define if the fresnel effect is enable or not.
  29883. */
  29884. isEnabled?: boolean;
  29885. };
  29886. /**
  29887. * Serialized format for FresnelParameters.
  29888. */
  29889. export type IFresnelParametersSerialized = {
  29890. /**
  29891. * Define the color used on edges (grazing angle) [as an array]
  29892. */
  29893. leftColor: number[];
  29894. /**
  29895. * Define the color used on center [as an array]
  29896. */
  29897. rightColor: number[];
  29898. /**
  29899. * Define bias applied to computed fresnel term
  29900. */
  29901. bias: number;
  29902. /**
  29903. * Defined the power exponent applied to fresnel term
  29904. */
  29905. power?: number;
  29906. /**
  29907. * Define if the fresnel effect is enable or not.
  29908. */
  29909. isEnabled: boolean;
  29910. };
  29911. /**
  29912. * This represents all the required information to add a fresnel effect on a material:
  29913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29914. */
  29915. export class FresnelParameters {
  29916. private _isEnabled;
  29917. /**
  29918. * Define if the fresnel effect is enable or not.
  29919. */
  29920. get isEnabled(): boolean;
  29921. set isEnabled(value: boolean);
  29922. /**
  29923. * Define the color used on edges (grazing angle)
  29924. */
  29925. leftColor: Color3;
  29926. /**
  29927. * Define the color used on center
  29928. */
  29929. rightColor: Color3;
  29930. /**
  29931. * Define bias applied to computed fresnel term
  29932. */
  29933. bias: number;
  29934. /**
  29935. * Defined the power exponent applied to fresnel term
  29936. */
  29937. power: number;
  29938. /**
  29939. * Creates a new FresnelParameters object.
  29940. *
  29941. * @param options provide your own settings to optionally to override defaults
  29942. */
  29943. constructor(options?: IFresnelParametersCreationOptions);
  29944. /**
  29945. * Clones the current fresnel and its valuues
  29946. * @returns a clone fresnel configuration
  29947. */
  29948. clone(): FresnelParameters;
  29949. /**
  29950. * Determines equality between FresnelParameters objects
  29951. * @param otherFresnelParameters defines the second operand
  29952. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29953. */
  29954. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29955. /**
  29956. * Serializes the current fresnel parameters to a JSON representation.
  29957. * @return the JSON serialization
  29958. */
  29959. serialize(): IFresnelParametersSerialized;
  29960. /**
  29961. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29962. * @param parsedFresnelParameters Define the JSON representation
  29963. * @returns the parsed parameters
  29964. */
  29965. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29966. }
  29967. }
  29968. declare module BABYLON {
  29969. /**
  29970. * This groups all the flags used to control the materials channel.
  29971. */
  29972. export class MaterialFlags {
  29973. private static _DiffuseTextureEnabled;
  29974. /**
  29975. * Are diffuse textures enabled in the application.
  29976. */
  29977. static get DiffuseTextureEnabled(): boolean;
  29978. static set DiffuseTextureEnabled(value: boolean);
  29979. private static _DetailTextureEnabled;
  29980. /**
  29981. * Are detail textures enabled in the application.
  29982. */
  29983. static get DetailTextureEnabled(): boolean;
  29984. static set DetailTextureEnabled(value: boolean);
  29985. private static _AmbientTextureEnabled;
  29986. /**
  29987. * Are ambient textures enabled in the application.
  29988. */
  29989. static get AmbientTextureEnabled(): boolean;
  29990. static set AmbientTextureEnabled(value: boolean);
  29991. private static _OpacityTextureEnabled;
  29992. /**
  29993. * Are opacity textures enabled in the application.
  29994. */
  29995. static get OpacityTextureEnabled(): boolean;
  29996. static set OpacityTextureEnabled(value: boolean);
  29997. private static _ReflectionTextureEnabled;
  29998. /**
  29999. * Are reflection textures enabled in the application.
  30000. */
  30001. static get ReflectionTextureEnabled(): boolean;
  30002. static set ReflectionTextureEnabled(value: boolean);
  30003. private static _EmissiveTextureEnabled;
  30004. /**
  30005. * Are emissive textures enabled in the application.
  30006. */
  30007. static get EmissiveTextureEnabled(): boolean;
  30008. static set EmissiveTextureEnabled(value: boolean);
  30009. private static _SpecularTextureEnabled;
  30010. /**
  30011. * Are specular textures enabled in the application.
  30012. */
  30013. static get SpecularTextureEnabled(): boolean;
  30014. static set SpecularTextureEnabled(value: boolean);
  30015. private static _BumpTextureEnabled;
  30016. /**
  30017. * Are bump textures enabled in the application.
  30018. */
  30019. static get BumpTextureEnabled(): boolean;
  30020. static set BumpTextureEnabled(value: boolean);
  30021. private static _LightmapTextureEnabled;
  30022. /**
  30023. * Are lightmap textures enabled in the application.
  30024. */
  30025. static get LightmapTextureEnabled(): boolean;
  30026. static set LightmapTextureEnabled(value: boolean);
  30027. private static _RefractionTextureEnabled;
  30028. /**
  30029. * Are refraction textures enabled in the application.
  30030. */
  30031. static get RefractionTextureEnabled(): boolean;
  30032. static set RefractionTextureEnabled(value: boolean);
  30033. private static _ColorGradingTextureEnabled;
  30034. /**
  30035. * Are color grading textures enabled in the application.
  30036. */
  30037. static get ColorGradingTextureEnabled(): boolean;
  30038. static set ColorGradingTextureEnabled(value: boolean);
  30039. private static _FresnelEnabled;
  30040. /**
  30041. * Are fresnels enabled in the application.
  30042. */
  30043. static get FresnelEnabled(): boolean;
  30044. static set FresnelEnabled(value: boolean);
  30045. private static _ClearCoatTextureEnabled;
  30046. /**
  30047. * Are clear coat textures enabled in the application.
  30048. */
  30049. static get ClearCoatTextureEnabled(): boolean;
  30050. static set ClearCoatTextureEnabled(value: boolean);
  30051. private static _ClearCoatBumpTextureEnabled;
  30052. /**
  30053. * Are clear coat bump textures enabled in the application.
  30054. */
  30055. static get ClearCoatBumpTextureEnabled(): boolean;
  30056. static set ClearCoatBumpTextureEnabled(value: boolean);
  30057. private static _ClearCoatTintTextureEnabled;
  30058. /**
  30059. * Are clear coat tint textures enabled in the application.
  30060. */
  30061. static get ClearCoatTintTextureEnabled(): boolean;
  30062. static set ClearCoatTintTextureEnabled(value: boolean);
  30063. private static _SheenTextureEnabled;
  30064. /**
  30065. * Are sheen textures enabled in the application.
  30066. */
  30067. static get SheenTextureEnabled(): boolean;
  30068. static set SheenTextureEnabled(value: boolean);
  30069. private static _AnisotropicTextureEnabled;
  30070. /**
  30071. * Are anisotropic textures enabled in the application.
  30072. */
  30073. static get AnisotropicTextureEnabled(): boolean;
  30074. static set AnisotropicTextureEnabled(value: boolean);
  30075. private static _ThicknessTextureEnabled;
  30076. /**
  30077. * Are thickness textures enabled in the application.
  30078. */
  30079. static get ThicknessTextureEnabled(): boolean;
  30080. static set ThicknessTextureEnabled(value: boolean);
  30081. }
  30082. }
  30083. declare module BABYLON {
  30084. /** @hidden */
  30085. export var defaultFragmentDeclaration: {
  30086. name: string;
  30087. shader: string;
  30088. };
  30089. }
  30090. declare module BABYLON {
  30091. /** @hidden */
  30092. export var defaultUboDeclaration: {
  30093. name: string;
  30094. shader: string;
  30095. };
  30096. }
  30097. declare module BABYLON {
  30098. /** @hidden */
  30099. export var prePassDeclaration: {
  30100. name: string;
  30101. shader: string;
  30102. };
  30103. }
  30104. declare module BABYLON {
  30105. /** @hidden */
  30106. export var lightFragmentDeclaration: {
  30107. name: string;
  30108. shader: string;
  30109. };
  30110. }
  30111. declare module BABYLON {
  30112. /** @hidden */
  30113. export var lightUboDeclaration: {
  30114. name: string;
  30115. shader: string;
  30116. };
  30117. }
  30118. declare module BABYLON {
  30119. /** @hidden */
  30120. export var lightsFragmentFunctions: {
  30121. name: string;
  30122. shader: string;
  30123. };
  30124. }
  30125. declare module BABYLON {
  30126. /** @hidden */
  30127. export var shadowsFragmentFunctions: {
  30128. name: string;
  30129. shader: string;
  30130. };
  30131. }
  30132. declare module BABYLON {
  30133. /** @hidden */
  30134. export var fresnelFunction: {
  30135. name: string;
  30136. shader: string;
  30137. };
  30138. }
  30139. declare module BABYLON {
  30140. /** @hidden */
  30141. export var bumpFragmentMainFunctions: {
  30142. name: string;
  30143. shader: string;
  30144. };
  30145. }
  30146. declare module BABYLON {
  30147. /** @hidden */
  30148. export var bumpFragmentFunctions: {
  30149. name: string;
  30150. shader: string;
  30151. };
  30152. }
  30153. declare module BABYLON {
  30154. /** @hidden */
  30155. export var logDepthDeclaration: {
  30156. name: string;
  30157. shader: string;
  30158. };
  30159. }
  30160. declare module BABYLON {
  30161. /** @hidden */
  30162. export var bumpFragment: {
  30163. name: string;
  30164. shader: string;
  30165. };
  30166. }
  30167. declare module BABYLON {
  30168. /** @hidden */
  30169. export var depthPrePass: {
  30170. name: string;
  30171. shader: string;
  30172. };
  30173. }
  30174. declare module BABYLON {
  30175. /** @hidden */
  30176. export var lightFragment: {
  30177. name: string;
  30178. shader: string;
  30179. };
  30180. }
  30181. declare module BABYLON {
  30182. /** @hidden */
  30183. export var logDepthFragment: {
  30184. name: string;
  30185. shader: string;
  30186. };
  30187. }
  30188. declare module BABYLON {
  30189. /** @hidden */
  30190. export var defaultPixelShader: {
  30191. name: string;
  30192. shader: string;
  30193. };
  30194. }
  30195. declare module BABYLON {
  30196. /** @hidden */
  30197. export var defaultVertexDeclaration: {
  30198. name: string;
  30199. shader: string;
  30200. };
  30201. }
  30202. declare module BABYLON {
  30203. /** @hidden */
  30204. export var bumpVertexDeclaration: {
  30205. name: string;
  30206. shader: string;
  30207. };
  30208. }
  30209. declare module BABYLON {
  30210. /** @hidden */
  30211. export var bumpVertex: {
  30212. name: string;
  30213. shader: string;
  30214. };
  30215. }
  30216. declare module BABYLON {
  30217. /** @hidden */
  30218. export var fogVertex: {
  30219. name: string;
  30220. shader: string;
  30221. };
  30222. }
  30223. declare module BABYLON {
  30224. /** @hidden */
  30225. export var shadowsVertex: {
  30226. name: string;
  30227. shader: string;
  30228. };
  30229. }
  30230. declare module BABYLON {
  30231. /** @hidden */
  30232. export var pointCloudVertex: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module BABYLON {
  30238. /** @hidden */
  30239. export var logDepthVertex: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module BABYLON {
  30245. /** @hidden */
  30246. export var defaultVertexShader: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module BABYLON {
  30252. /**
  30253. * @hidden
  30254. */
  30255. export interface IMaterialDetailMapDefines {
  30256. DETAIL: boolean;
  30257. DETAILDIRECTUV: number;
  30258. DETAIL_NORMALBLENDMETHOD: number;
  30259. /** @hidden */
  30260. _areTexturesDirty: boolean;
  30261. }
  30262. /**
  30263. * Define the code related to the detail map parameters of a material
  30264. *
  30265. * Inspired from:
  30266. * 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
  30267. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30268. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30269. */
  30270. export class DetailMapConfiguration {
  30271. private _texture;
  30272. /**
  30273. * The detail texture of the material.
  30274. */
  30275. texture: Nullable<BaseTexture>;
  30276. /**
  30277. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30278. * Bigger values mean stronger blending
  30279. */
  30280. diffuseBlendLevel: number;
  30281. /**
  30282. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30283. * Bigger values mean stronger blending. Only used with PBR materials
  30284. */
  30285. roughnessBlendLevel: number;
  30286. /**
  30287. * Defines how strong the bump effect from the detail map is
  30288. * Bigger values mean stronger effect
  30289. */
  30290. bumpLevel: number;
  30291. private _normalBlendMethod;
  30292. /**
  30293. * The method used to blend the bump and detail normals together
  30294. */
  30295. normalBlendMethod: number;
  30296. private _isEnabled;
  30297. /**
  30298. * Enable or disable the detail map on this material
  30299. */
  30300. isEnabled: boolean;
  30301. /** @hidden */
  30302. private _internalMarkAllSubMeshesAsTexturesDirty;
  30303. /** @hidden */
  30304. _markAllSubMeshesAsTexturesDirty(): void;
  30305. /**
  30306. * Instantiate a new detail map
  30307. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30308. */
  30309. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30310. /**
  30311. * Gets whether the submesh is ready to be used or not.
  30312. * @param defines the list of "defines" to update.
  30313. * @param scene defines the scene the material belongs to.
  30314. * @returns - boolean indicating that the submesh is ready or not.
  30315. */
  30316. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30317. /**
  30318. * Update the defines for detail map usage
  30319. * @param defines the list of "defines" to update.
  30320. * @param scene defines the scene the material belongs to.
  30321. */
  30322. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30323. /**
  30324. * Binds the material data.
  30325. * @param uniformBuffer defines the Uniform buffer to fill in.
  30326. * @param scene defines the scene the material belongs to.
  30327. * @param isFrozen defines whether the material is frozen or not.
  30328. */
  30329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30330. /**
  30331. * Checks to see if a texture is used in the material.
  30332. * @param texture - Base texture to use.
  30333. * @returns - Boolean specifying if a texture is used in the material.
  30334. */
  30335. hasTexture(texture: BaseTexture): boolean;
  30336. /**
  30337. * Returns an array of the actively used textures.
  30338. * @param activeTextures Array of BaseTextures
  30339. */
  30340. getActiveTextures(activeTextures: BaseTexture[]): void;
  30341. /**
  30342. * Returns the animatable textures.
  30343. * @param animatables Array of animatable textures.
  30344. */
  30345. getAnimatables(animatables: IAnimatable[]): void;
  30346. /**
  30347. * Disposes the resources of the material.
  30348. * @param forceDisposeTextures - Forces the disposal of all textures.
  30349. */
  30350. dispose(forceDisposeTextures?: boolean): void;
  30351. /**
  30352. * Get the current class name useful for serialization or dynamic coding.
  30353. * @returns "DetailMap"
  30354. */
  30355. getClassName(): string;
  30356. /**
  30357. * Add the required uniforms to the current list.
  30358. * @param uniforms defines the current uniform list.
  30359. */
  30360. static AddUniforms(uniforms: string[]): void;
  30361. /**
  30362. * Add the required samplers to the current list.
  30363. * @param samplers defines the current sampler list.
  30364. */
  30365. static AddSamplers(samplers: string[]): void;
  30366. /**
  30367. * Add the required uniforms to the current buffer.
  30368. * @param uniformBuffer defines the current uniform buffer.
  30369. */
  30370. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30371. /**
  30372. * Makes a duplicate of the current instance into another one.
  30373. * @param detailMap define the instance where to copy the info
  30374. */
  30375. copyTo(detailMap: DetailMapConfiguration): void;
  30376. /**
  30377. * Serializes this detail map instance
  30378. * @returns - An object with the serialized instance.
  30379. */
  30380. serialize(): any;
  30381. /**
  30382. * Parses a detail map setting from a serialized object.
  30383. * @param source - Serialized object.
  30384. * @param scene Defines the scene we are parsing for
  30385. * @param rootUrl Defines the rootUrl to load from
  30386. */
  30387. parse(source: any, scene: Scene, rootUrl: string): void;
  30388. }
  30389. }
  30390. declare module BABYLON {
  30391. /** @hidden */
  30392. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30393. MAINUV1: boolean;
  30394. MAINUV2: boolean;
  30395. DIFFUSE: boolean;
  30396. DIFFUSEDIRECTUV: number;
  30397. DETAIL: boolean;
  30398. DETAILDIRECTUV: number;
  30399. DETAIL_NORMALBLENDMETHOD: number;
  30400. AMBIENT: boolean;
  30401. AMBIENTDIRECTUV: number;
  30402. OPACITY: boolean;
  30403. OPACITYDIRECTUV: number;
  30404. OPACITYRGB: boolean;
  30405. REFLECTION: boolean;
  30406. EMISSIVE: boolean;
  30407. EMISSIVEDIRECTUV: number;
  30408. SPECULAR: boolean;
  30409. SPECULARDIRECTUV: number;
  30410. BUMP: boolean;
  30411. BUMPDIRECTUV: number;
  30412. PARALLAX: boolean;
  30413. PARALLAXOCCLUSION: boolean;
  30414. SPECULAROVERALPHA: boolean;
  30415. CLIPPLANE: boolean;
  30416. CLIPPLANE2: boolean;
  30417. CLIPPLANE3: boolean;
  30418. CLIPPLANE4: boolean;
  30419. CLIPPLANE5: boolean;
  30420. CLIPPLANE6: boolean;
  30421. ALPHATEST: boolean;
  30422. DEPTHPREPASS: boolean;
  30423. ALPHAFROMDIFFUSE: boolean;
  30424. POINTSIZE: boolean;
  30425. FOG: boolean;
  30426. SPECULARTERM: boolean;
  30427. DIFFUSEFRESNEL: boolean;
  30428. OPACITYFRESNEL: boolean;
  30429. REFLECTIONFRESNEL: boolean;
  30430. REFRACTIONFRESNEL: boolean;
  30431. EMISSIVEFRESNEL: boolean;
  30432. FRESNEL: boolean;
  30433. NORMAL: boolean;
  30434. UV1: boolean;
  30435. UV2: boolean;
  30436. VERTEXCOLOR: boolean;
  30437. VERTEXALPHA: boolean;
  30438. NUM_BONE_INFLUENCERS: number;
  30439. BonesPerMesh: number;
  30440. BONETEXTURE: boolean;
  30441. INSTANCES: boolean;
  30442. THIN_INSTANCES: boolean;
  30443. GLOSSINESS: boolean;
  30444. ROUGHNESS: boolean;
  30445. EMISSIVEASILLUMINATION: boolean;
  30446. LINKEMISSIVEWITHDIFFUSE: boolean;
  30447. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30448. LIGHTMAP: boolean;
  30449. LIGHTMAPDIRECTUV: number;
  30450. OBJECTSPACE_NORMALMAP: boolean;
  30451. USELIGHTMAPASSHADOWMAP: boolean;
  30452. REFLECTIONMAP_3D: boolean;
  30453. REFLECTIONMAP_SPHERICAL: boolean;
  30454. REFLECTIONMAP_PLANAR: boolean;
  30455. REFLECTIONMAP_CUBIC: boolean;
  30456. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30457. REFLECTIONMAP_PROJECTION: boolean;
  30458. REFLECTIONMAP_SKYBOX: boolean;
  30459. REFLECTIONMAP_EXPLICIT: boolean;
  30460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30463. INVERTCUBICMAP: boolean;
  30464. LOGARITHMICDEPTH: boolean;
  30465. REFRACTION: boolean;
  30466. REFRACTIONMAP_3D: boolean;
  30467. REFLECTIONOVERALPHA: boolean;
  30468. TWOSIDEDLIGHTING: boolean;
  30469. SHADOWFLOAT: boolean;
  30470. MORPHTARGETS: boolean;
  30471. MORPHTARGETS_NORMAL: boolean;
  30472. MORPHTARGETS_TANGENT: boolean;
  30473. MORPHTARGETS_UV: boolean;
  30474. NUM_MORPH_INFLUENCERS: number;
  30475. NONUNIFORMSCALING: boolean;
  30476. PREMULTIPLYALPHA: boolean;
  30477. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30478. ALPHABLEND: boolean;
  30479. PREPASS: boolean;
  30480. SCENE_MRT_COUNT: number;
  30481. RGBDLIGHTMAP: boolean;
  30482. RGBDREFLECTION: boolean;
  30483. RGBDREFRACTION: boolean;
  30484. IMAGEPROCESSING: boolean;
  30485. VIGNETTE: boolean;
  30486. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30487. VIGNETTEBLENDMODEOPAQUE: boolean;
  30488. TONEMAPPING: boolean;
  30489. TONEMAPPING_ACES: boolean;
  30490. CONTRAST: boolean;
  30491. COLORCURVES: boolean;
  30492. COLORGRADING: boolean;
  30493. COLORGRADING3D: boolean;
  30494. SAMPLER3DGREENDEPTH: boolean;
  30495. SAMPLER3DBGRMAP: boolean;
  30496. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30497. MULTIVIEW: boolean;
  30498. /**
  30499. * If the reflection texture on this material is in linear color space
  30500. * @hidden
  30501. */
  30502. IS_REFLECTION_LINEAR: boolean;
  30503. /**
  30504. * If the refraction texture on this material is in linear color space
  30505. * @hidden
  30506. */
  30507. IS_REFRACTION_LINEAR: boolean;
  30508. EXPOSURE: boolean;
  30509. constructor();
  30510. setReflectionMode(modeToEnable: string): void;
  30511. }
  30512. /**
  30513. * This is the default material used in Babylon. It is the best trade off between quality
  30514. * and performances.
  30515. * @see https://doc.babylonjs.com/babylon101/materials
  30516. */
  30517. export class StandardMaterial extends PushMaterial {
  30518. private _diffuseTexture;
  30519. /**
  30520. * The basic texture of the material as viewed under a light.
  30521. */
  30522. diffuseTexture: Nullable<BaseTexture>;
  30523. private _ambientTexture;
  30524. /**
  30525. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30526. */
  30527. ambientTexture: Nullable<BaseTexture>;
  30528. private _opacityTexture;
  30529. /**
  30530. * Define the transparency of the material from a texture.
  30531. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30532. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30533. */
  30534. opacityTexture: Nullable<BaseTexture>;
  30535. private _reflectionTexture;
  30536. /**
  30537. * Define the texture used to display the reflection.
  30538. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30539. */
  30540. reflectionTexture: Nullable<BaseTexture>;
  30541. private _emissiveTexture;
  30542. /**
  30543. * Define texture of the material as if self lit.
  30544. * This will be mixed in the final result even in the absence of light.
  30545. */
  30546. emissiveTexture: Nullable<BaseTexture>;
  30547. private _specularTexture;
  30548. /**
  30549. * Define how the color and intensity of the highlight given by the light in the material.
  30550. */
  30551. specularTexture: Nullable<BaseTexture>;
  30552. private _bumpTexture;
  30553. /**
  30554. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30555. * 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.
  30556. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30557. */
  30558. bumpTexture: Nullable<BaseTexture>;
  30559. private _lightmapTexture;
  30560. /**
  30561. * Complex lighting can be computationally expensive to compute at runtime.
  30562. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30563. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30564. */
  30565. lightmapTexture: Nullable<BaseTexture>;
  30566. private _refractionTexture;
  30567. /**
  30568. * Define the texture used to display the refraction.
  30569. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30570. */
  30571. refractionTexture: Nullable<BaseTexture>;
  30572. /**
  30573. * The color of the material lit by the environmental background lighting.
  30574. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30575. */
  30576. ambientColor: Color3;
  30577. /**
  30578. * The basic color of the material as viewed under a light.
  30579. */
  30580. diffuseColor: Color3;
  30581. /**
  30582. * Define how the color and intensity of the highlight given by the light in the material.
  30583. */
  30584. specularColor: Color3;
  30585. /**
  30586. * Define the color of the material as if self lit.
  30587. * This will be mixed in the final result even in the absence of light.
  30588. */
  30589. emissiveColor: Color3;
  30590. /**
  30591. * Defines how sharp are the highlights in the material.
  30592. * The bigger the value the sharper giving a more glossy feeling to the result.
  30593. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30594. */
  30595. specularPower: number;
  30596. private _useAlphaFromDiffuseTexture;
  30597. /**
  30598. * Does the transparency come from the diffuse texture alpha channel.
  30599. */
  30600. useAlphaFromDiffuseTexture: boolean;
  30601. private _useEmissiveAsIllumination;
  30602. /**
  30603. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30604. */
  30605. useEmissiveAsIllumination: boolean;
  30606. private _linkEmissiveWithDiffuse;
  30607. /**
  30608. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30609. * the emissive level when the final color is close to one.
  30610. */
  30611. linkEmissiveWithDiffuse: boolean;
  30612. private _useSpecularOverAlpha;
  30613. /**
  30614. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30615. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30616. */
  30617. useSpecularOverAlpha: boolean;
  30618. private _useReflectionOverAlpha;
  30619. /**
  30620. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30621. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30622. */
  30623. useReflectionOverAlpha: boolean;
  30624. private _disableLighting;
  30625. /**
  30626. * Does lights from the scene impacts this material.
  30627. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30628. */
  30629. disableLighting: boolean;
  30630. private _useObjectSpaceNormalMap;
  30631. /**
  30632. * Allows using an object space normal map (instead of tangent space).
  30633. */
  30634. useObjectSpaceNormalMap: boolean;
  30635. private _useParallax;
  30636. /**
  30637. * Is parallax enabled or not.
  30638. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30639. */
  30640. useParallax: boolean;
  30641. private _useParallaxOcclusion;
  30642. /**
  30643. * Is parallax occlusion enabled or not.
  30644. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30645. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30646. */
  30647. useParallaxOcclusion: boolean;
  30648. /**
  30649. * 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.
  30650. */
  30651. parallaxScaleBias: number;
  30652. private _roughness;
  30653. /**
  30654. * Helps to define how blurry the reflections should appears in the material.
  30655. */
  30656. roughness: number;
  30657. /**
  30658. * In case of refraction, define the value of the index of refraction.
  30659. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30660. */
  30661. indexOfRefraction: number;
  30662. /**
  30663. * Invert the refraction texture alongside the y axis.
  30664. * It can be useful with procedural textures or probe for instance.
  30665. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30666. */
  30667. invertRefractionY: boolean;
  30668. /**
  30669. * Defines the alpha limits in alpha test mode.
  30670. */
  30671. alphaCutOff: number;
  30672. private _useLightmapAsShadowmap;
  30673. /**
  30674. * In case of light mapping, define whether the map contains light or shadow informations.
  30675. */
  30676. useLightmapAsShadowmap: boolean;
  30677. private _diffuseFresnelParameters;
  30678. /**
  30679. * Define the diffuse fresnel parameters of the material.
  30680. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30681. */
  30682. diffuseFresnelParameters: FresnelParameters;
  30683. private _opacityFresnelParameters;
  30684. /**
  30685. * Define the opacity fresnel parameters of the material.
  30686. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30687. */
  30688. opacityFresnelParameters: FresnelParameters;
  30689. private _reflectionFresnelParameters;
  30690. /**
  30691. * Define the reflection fresnel parameters of the material.
  30692. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30693. */
  30694. reflectionFresnelParameters: FresnelParameters;
  30695. private _refractionFresnelParameters;
  30696. /**
  30697. * Define the refraction fresnel parameters of the material.
  30698. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30699. */
  30700. refractionFresnelParameters: FresnelParameters;
  30701. private _emissiveFresnelParameters;
  30702. /**
  30703. * Define the emissive fresnel parameters of the material.
  30704. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30705. */
  30706. emissiveFresnelParameters: FresnelParameters;
  30707. private _useReflectionFresnelFromSpecular;
  30708. /**
  30709. * If true automatically deducts the fresnels values from the material specularity.
  30710. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30711. */
  30712. useReflectionFresnelFromSpecular: boolean;
  30713. private _useGlossinessFromSpecularMapAlpha;
  30714. /**
  30715. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30716. */
  30717. useGlossinessFromSpecularMapAlpha: boolean;
  30718. private _maxSimultaneousLights;
  30719. /**
  30720. * Defines the maximum number of lights that can be used in the material
  30721. */
  30722. maxSimultaneousLights: number;
  30723. private _invertNormalMapX;
  30724. /**
  30725. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30726. */
  30727. invertNormalMapX: boolean;
  30728. private _invertNormalMapY;
  30729. /**
  30730. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30731. */
  30732. invertNormalMapY: boolean;
  30733. private _twoSidedLighting;
  30734. /**
  30735. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30736. */
  30737. twoSidedLighting: boolean;
  30738. /**
  30739. * Default configuration related to image processing available in the standard Material.
  30740. */
  30741. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30742. /**
  30743. * Gets the image processing configuration used either in this material.
  30744. */
  30745. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30746. /**
  30747. * Sets the Default image processing configuration used either in the this material.
  30748. *
  30749. * If sets to null, the scene one is in use.
  30750. */
  30751. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30752. /**
  30753. * Keep track of the image processing observer to allow dispose and replace.
  30754. */
  30755. private _imageProcessingObserver;
  30756. /**
  30757. * Attaches a new image processing configuration to the Standard Material.
  30758. * @param configuration
  30759. */
  30760. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30761. /**
  30762. * Gets wether the color curves effect is enabled.
  30763. */
  30764. get cameraColorCurvesEnabled(): boolean;
  30765. /**
  30766. * Sets wether the color curves effect is enabled.
  30767. */
  30768. set cameraColorCurvesEnabled(value: boolean);
  30769. /**
  30770. * Gets wether the color grading effect is enabled.
  30771. */
  30772. get cameraColorGradingEnabled(): boolean;
  30773. /**
  30774. * Gets wether the color grading effect is enabled.
  30775. */
  30776. set cameraColorGradingEnabled(value: boolean);
  30777. /**
  30778. * Gets wether tonemapping is enabled or not.
  30779. */
  30780. get cameraToneMappingEnabled(): boolean;
  30781. /**
  30782. * Sets wether tonemapping is enabled or not
  30783. */
  30784. set cameraToneMappingEnabled(value: boolean);
  30785. /**
  30786. * The camera exposure used on this material.
  30787. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30788. * This corresponds to a photographic exposure.
  30789. */
  30790. get cameraExposure(): number;
  30791. /**
  30792. * The camera exposure used on this material.
  30793. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30794. * This corresponds to a photographic exposure.
  30795. */
  30796. set cameraExposure(value: number);
  30797. /**
  30798. * Gets The camera contrast used on this material.
  30799. */
  30800. get cameraContrast(): number;
  30801. /**
  30802. * Sets The camera contrast used on this material.
  30803. */
  30804. set cameraContrast(value: number);
  30805. /**
  30806. * Gets the Color Grading 2D Lookup Texture.
  30807. */
  30808. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30809. /**
  30810. * Sets the Color Grading 2D Lookup Texture.
  30811. */
  30812. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30813. /**
  30814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30816. * 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;
  30817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30818. */
  30819. get cameraColorCurves(): Nullable<ColorCurves>;
  30820. /**
  30821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30823. * 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;
  30824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30825. */
  30826. set cameraColorCurves(value: Nullable<ColorCurves>);
  30827. /**
  30828. * Can this material render to several textures at once
  30829. */
  30830. get canRenderToMRT(): boolean;
  30831. /**
  30832. * Defines the detail map parameters for the material.
  30833. */
  30834. readonly detailMap: DetailMapConfiguration;
  30835. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30836. protected _worldViewProjectionMatrix: Matrix;
  30837. protected _globalAmbientColor: Color3;
  30838. protected _useLogarithmicDepth: boolean;
  30839. protected _rebuildInParallel: boolean;
  30840. /**
  30841. * Instantiates a new standard material.
  30842. * This is the default material used in Babylon. It is the best trade off between quality
  30843. * and performances.
  30844. * @see https://doc.babylonjs.com/babylon101/materials
  30845. * @param name Define the name of the material in the scene
  30846. * @param scene Define the scene the material belong to
  30847. */
  30848. constructor(name: string, scene: Scene);
  30849. /**
  30850. * Gets a boolean indicating that current material needs to register RTT
  30851. */
  30852. get hasRenderTargetTextures(): boolean;
  30853. /**
  30854. * Gets the current class name of the material e.g. "StandardMaterial"
  30855. * Mainly use in serialization.
  30856. * @returns the class name
  30857. */
  30858. getClassName(): string;
  30859. /**
  30860. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30861. * You can try switching to logarithmic depth.
  30862. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30863. */
  30864. get useLogarithmicDepth(): boolean;
  30865. set useLogarithmicDepth(value: boolean);
  30866. /**
  30867. * Specifies if the material will require alpha blending
  30868. * @returns a boolean specifying if alpha blending is needed
  30869. */
  30870. needAlphaBlending(): boolean;
  30871. /**
  30872. * Specifies if this material should be rendered in alpha test mode
  30873. * @returns a boolean specifying if an alpha test is needed.
  30874. */
  30875. needAlphaTesting(): boolean;
  30876. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30877. /**
  30878. * Get the texture used for alpha test purpose.
  30879. * @returns the diffuse texture in case of the standard material.
  30880. */
  30881. getAlphaTestTexture(): Nullable<BaseTexture>;
  30882. /**
  30883. * Get if the submesh is ready to be used and all its information available.
  30884. * Child classes can use it to update shaders
  30885. * @param mesh defines the mesh to check
  30886. * @param subMesh defines which submesh to check
  30887. * @param useInstances specifies that instances should be used
  30888. * @returns a boolean indicating that the submesh is ready or not
  30889. */
  30890. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30891. /**
  30892. * Builds the material UBO layouts.
  30893. * Used internally during the effect preparation.
  30894. */
  30895. buildUniformLayout(): void;
  30896. /**
  30897. * Unbinds the material from the mesh
  30898. */
  30899. unbind(): void;
  30900. /**
  30901. * Binds the submesh to this material by preparing the effect and shader to draw
  30902. * @param world defines the world transformation matrix
  30903. * @param mesh defines the mesh containing the submesh
  30904. * @param subMesh defines the submesh to bind the material to
  30905. */
  30906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30907. /**
  30908. * Get the list of animatables in the material.
  30909. * @returns the list of animatables object used in the material
  30910. */
  30911. getAnimatables(): IAnimatable[];
  30912. /**
  30913. * Gets the active textures from the material
  30914. * @returns an array of textures
  30915. */
  30916. getActiveTextures(): BaseTexture[];
  30917. /**
  30918. * Specifies if the material uses a texture
  30919. * @param texture defines the texture to check against the material
  30920. * @returns a boolean specifying if the material uses the texture
  30921. */
  30922. hasTexture(texture: BaseTexture): boolean;
  30923. /**
  30924. * Disposes the material
  30925. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30926. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30927. */
  30928. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30929. /**
  30930. * Makes a duplicate of the material, and gives it a new name
  30931. * @param name defines the new name for the duplicated material
  30932. * @returns the cloned material
  30933. */
  30934. clone(name: string): StandardMaterial;
  30935. /**
  30936. * Serializes this material in a JSON representation
  30937. * @returns the serialized material object
  30938. */
  30939. serialize(): any;
  30940. /**
  30941. * Creates a standard material from parsed material data
  30942. * @param source defines the JSON representation of the material
  30943. * @param scene defines the hosting scene
  30944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30945. * @returns a new standard material
  30946. */
  30947. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30948. /**
  30949. * Are diffuse textures enabled in the application.
  30950. */
  30951. static get DiffuseTextureEnabled(): boolean;
  30952. static set DiffuseTextureEnabled(value: boolean);
  30953. /**
  30954. * Are detail textures enabled in the application.
  30955. */
  30956. static get DetailTextureEnabled(): boolean;
  30957. static set DetailTextureEnabled(value: boolean);
  30958. /**
  30959. * Are ambient textures enabled in the application.
  30960. */
  30961. static get AmbientTextureEnabled(): boolean;
  30962. static set AmbientTextureEnabled(value: boolean);
  30963. /**
  30964. * Are opacity textures enabled in the application.
  30965. */
  30966. static get OpacityTextureEnabled(): boolean;
  30967. static set OpacityTextureEnabled(value: boolean);
  30968. /**
  30969. * Are reflection textures enabled in the application.
  30970. */
  30971. static get ReflectionTextureEnabled(): boolean;
  30972. static set ReflectionTextureEnabled(value: boolean);
  30973. /**
  30974. * Are emissive textures enabled in the application.
  30975. */
  30976. static get EmissiveTextureEnabled(): boolean;
  30977. static set EmissiveTextureEnabled(value: boolean);
  30978. /**
  30979. * Are specular textures enabled in the application.
  30980. */
  30981. static get SpecularTextureEnabled(): boolean;
  30982. static set SpecularTextureEnabled(value: boolean);
  30983. /**
  30984. * Are bump textures enabled in the application.
  30985. */
  30986. static get BumpTextureEnabled(): boolean;
  30987. static set BumpTextureEnabled(value: boolean);
  30988. /**
  30989. * Are lightmap textures enabled in the application.
  30990. */
  30991. static get LightmapTextureEnabled(): boolean;
  30992. static set LightmapTextureEnabled(value: boolean);
  30993. /**
  30994. * Are refraction textures enabled in the application.
  30995. */
  30996. static get RefractionTextureEnabled(): boolean;
  30997. static set RefractionTextureEnabled(value: boolean);
  30998. /**
  30999. * Are color grading textures enabled in the application.
  31000. */
  31001. static get ColorGradingTextureEnabled(): boolean;
  31002. static set ColorGradingTextureEnabled(value: boolean);
  31003. /**
  31004. * Are fresnels enabled in the application.
  31005. */
  31006. static get FresnelEnabled(): boolean;
  31007. static set FresnelEnabled(value: boolean);
  31008. }
  31009. }
  31010. declare module BABYLON {
  31011. /**
  31012. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31013. *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.
  31014. * The SPS is also a particle system. It provides some methods to manage the particles.
  31015. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31016. *
  31017. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31018. */
  31019. export class SolidParticleSystem implements IDisposable {
  31020. /**
  31021. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31022. * Example : var p = SPS.particles[i];
  31023. */
  31024. particles: SolidParticle[];
  31025. /**
  31026. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31027. */
  31028. nbParticles: number;
  31029. /**
  31030. * If the particles must ever face the camera (default false). Useful for planar particles.
  31031. */
  31032. billboard: boolean;
  31033. /**
  31034. * Recompute normals when adding a shape
  31035. */
  31036. recomputeNormals: boolean;
  31037. /**
  31038. * This a counter ofr your own usage. It's not set by any SPS functions.
  31039. */
  31040. counter: number;
  31041. /**
  31042. * The SPS name. This name is also given to the underlying mesh.
  31043. */
  31044. name: string;
  31045. /**
  31046. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31047. */
  31048. mesh: Mesh;
  31049. /**
  31050. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31051. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31052. */
  31053. vars: any;
  31054. /**
  31055. * This array is populated when the SPS is set as 'pickable'.
  31056. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31057. * Each element of this array is an object `{idx: int, faceId: int}`.
  31058. * `idx` is the picked particle index in the `SPS.particles` array
  31059. * `faceId` is the picked face index counted within this particle.
  31060. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31061. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31062. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31063. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31064. */
  31065. pickedParticles: {
  31066. idx: number;
  31067. faceId: number;
  31068. }[];
  31069. /**
  31070. * This array is populated when the SPS is set as 'pickable'
  31071. * Each key of this array is a submesh index.
  31072. * Each element of this array is a second array defined like this :
  31073. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31074. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31075. * `idx` is the picked particle index in the `SPS.particles` array
  31076. * `faceId` is the picked face index counted within this particle.
  31077. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31078. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31079. */
  31080. pickedBySubMesh: {
  31081. idx: number;
  31082. faceId: number;
  31083. }[][];
  31084. /**
  31085. * This array is populated when `enableDepthSort` is set to true.
  31086. * Each element of this array is an instance of the class DepthSortedParticle.
  31087. */
  31088. depthSortedParticles: DepthSortedParticle[];
  31089. /**
  31090. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31091. * @hidden
  31092. */
  31093. _bSphereOnly: boolean;
  31094. /**
  31095. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31096. * @hidden
  31097. */
  31098. _bSphereRadiusFactor: number;
  31099. private _scene;
  31100. private _positions;
  31101. private _indices;
  31102. private _normals;
  31103. private _colors;
  31104. private _uvs;
  31105. private _indices32;
  31106. private _positions32;
  31107. private _normals32;
  31108. private _fixedNormal32;
  31109. private _colors32;
  31110. private _uvs32;
  31111. private _index;
  31112. private _updatable;
  31113. private _pickable;
  31114. private _isVisibilityBoxLocked;
  31115. private _alwaysVisible;
  31116. private _depthSort;
  31117. private _expandable;
  31118. private _shapeCounter;
  31119. private _copy;
  31120. private _color;
  31121. private _computeParticleColor;
  31122. private _computeParticleTexture;
  31123. private _computeParticleRotation;
  31124. private _computeParticleVertex;
  31125. private _computeBoundingBox;
  31126. private _depthSortParticles;
  31127. private _camera;
  31128. private _mustUnrotateFixedNormals;
  31129. private _particlesIntersect;
  31130. private _needs32Bits;
  31131. private _isNotBuilt;
  31132. private _lastParticleId;
  31133. private _idxOfId;
  31134. private _multimaterialEnabled;
  31135. private _useModelMaterial;
  31136. private _indicesByMaterial;
  31137. private _materialIndexes;
  31138. private _depthSortFunction;
  31139. private _materialSortFunction;
  31140. private _materials;
  31141. private _multimaterial;
  31142. private _materialIndexesById;
  31143. private _defaultMaterial;
  31144. private _autoUpdateSubMeshes;
  31145. private _tmpVertex;
  31146. /**
  31147. * Creates a SPS (Solid Particle System) object.
  31148. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31149. * @param scene (Scene) is the scene in which the SPS is added.
  31150. * @param options defines the options of the sps e.g.
  31151. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31152. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31153. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31154. * * 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.
  31155. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31156. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31157. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31158. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31159. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31160. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31161. */
  31162. constructor(name: string, scene: Scene, options?: {
  31163. updatable?: boolean;
  31164. isPickable?: boolean;
  31165. enableDepthSort?: boolean;
  31166. particleIntersection?: boolean;
  31167. boundingSphereOnly?: boolean;
  31168. bSphereRadiusFactor?: number;
  31169. expandable?: boolean;
  31170. useModelMaterial?: boolean;
  31171. enableMultiMaterial?: boolean;
  31172. });
  31173. /**
  31174. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31175. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31176. * @returns the created mesh
  31177. */
  31178. buildMesh(): Mesh;
  31179. /**
  31180. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31181. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31182. * Thus the particles generated from `digest()` have their property `position` set yet.
  31183. * @param mesh ( Mesh ) is the mesh to be digested
  31184. * @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
  31185. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31186. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31187. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31188. * @returns the current SPS
  31189. */
  31190. digest(mesh: Mesh, options?: {
  31191. facetNb?: number;
  31192. number?: number;
  31193. delta?: number;
  31194. storage?: [];
  31195. }): SolidParticleSystem;
  31196. /**
  31197. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31198. * @hidden
  31199. */
  31200. private _unrotateFixedNormals;
  31201. /**
  31202. * Resets the temporary working copy particle
  31203. * @hidden
  31204. */
  31205. private _resetCopy;
  31206. /**
  31207. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31208. * @param p the current index in the positions array to be updated
  31209. * @param ind the current index in the indices array
  31210. * @param shape a Vector3 array, the shape geometry
  31211. * @param positions the positions array to be updated
  31212. * @param meshInd the shape indices array
  31213. * @param indices the indices array to be updated
  31214. * @param meshUV the shape uv array
  31215. * @param uvs the uv array to be updated
  31216. * @param meshCol the shape color array
  31217. * @param colors the color array to be updated
  31218. * @param meshNor the shape normals array
  31219. * @param normals the normals array to be updated
  31220. * @param idx the particle index
  31221. * @param idxInShape the particle index in its shape
  31222. * @param options the addShape() method passed options
  31223. * @model the particle model
  31224. * @hidden
  31225. */
  31226. private _meshBuilder;
  31227. /**
  31228. * Returns a shape Vector3 array from positions float array
  31229. * @param positions float array
  31230. * @returns a vector3 array
  31231. * @hidden
  31232. */
  31233. private _posToShape;
  31234. /**
  31235. * Returns a shapeUV array from a float uvs (array deep copy)
  31236. * @param uvs as a float array
  31237. * @returns a shapeUV array
  31238. * @hidden
  31239. */
  31240. private _uvsToShapeUV;
  31241. /**
  31242. * Adds a new particle object in the particles array
  31243. * @param idx particle index in particles array
  31244. * @param id particle id
  31245. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31246. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31247. * @param model particle ModelShape object
  31248. * @param shapeId model shape identifier
  31249. * @param idxInShape index of the particle in the current model
  31250. * @param bInfo model bounding info object
  31251. * @param storage target storage array, if any
  31252. * @hidden
  31253. */
  31254. private _addParticle;
  31255. /**
  31256. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31257. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31258. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31259. * @param nb (positive integer) the number of particles to be created from this model
  31260. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31261. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31262. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31263. * @returns the number of shapes in the system
  31264. */
  31265. addShape(mesh: Mesh, nb: number, options?: {
  31266. positionFunction?: any;
  31267. vertexFunction?: any;
  31268. storage?: [];
  31269. }): number;
  31270. /**
  31271. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31272. * @hidden
  31273. */
  31274. private _rebuildParticle;
  31275. /**
  31276. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31277. * @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.
  31278. * @returns the SPS.
  31279. */
  31280. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31281. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31282. * Returns an array with the removed particles.
  31283. * 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.
  31284. * The SPS can't be empty so at least one particle needs to remain in place.
  31285. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31286. * @param start index of the first particle to remove
  31287. * @param end index of the last particle to remove (included)
  31288. * @returns an array populated with the removed particles
  31289. */
  31290. removeParticles(start: number, end: number): SolidParticle[];
  31291. /**
  31292. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31293. * @param solidParticleArray an array populated with Solid Particles objects
  31294. * @returns the SPS
  31295. */
  31296. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31297. /**
  31298. * Creates a new particle and modifies the SPS mesh geometry :
  31299. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31300. * - calls _addParticle() to populate the particle array
  31301. * factorized code from addShape() and insertParticlesFromArray()
  31302. * @param idx particle index in the particles array
  31303. * @param i particle index in its shape
  31304. * @param modelShape particle ModelShape object
  31305. * @param shape shape vertex array
  31306. * @param meshInd shape indices array
  31307. * @param meshUV shape uv array
  31308. * @param meshCol shape color array
  31309. * @param meshNor shape normals array
  31310. * @param bbInfo shape bounding info
  31311. * @param storage target particle storage
  31312. * @options addShape() passed options
  31313. * @hidden
  31314. */
  31315. private _insertNewParticle;
  31316. /**
  31317. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31318. * This method calls `updateParticle()` for each particle of the SPS.
  31319. * For an animated SPS, it is usually called within the render loop.
  31320. * 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.
  31321. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31322. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31323. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31324. * @returns the SPS.
  31325. */
  31326. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31327. /**
  31328. * Disposes the SPS.
  31329. */
  31330. dispose(): void;
  31331. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31332. * idx is the particle index in the SPS
  31333. * faceId is the picked face index counted within this particle.
  31334. * Returns null if the pickInfo can't identify a picked particle.
  31335. * @param pickingInfo (PickingInfo object)
  31336. * @returns {idx: number, faceId: number} or null
  31337. */
  31338. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31339. idx: number;
  31340. faceId: number;
  31341. }>;
  31342. /**
  31343. * Returns a SolidParticle object from its identifier : particle.id
  31344. * @param id (integer) the particle Id
  31345. * @returns the searched particle or null if not found in the SPS.
  31346. */
  31347. getParticleById(id: number): Nullable<SolidParticle>;
  31348. /**
  31349. * Returns a new array populated with the particles having the passed shapeId.
  31350. * @param shapeId (integer) the shape identifier
  31351. * @returns a new solid particle array
  31352. */
  31353. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31354. /**
  31355. * Populates the passed array "ref" with the particles having the passed shapeId.
  31356. * @param shapeId the shape identifier
  31357. * @returns the SPS
  31358. * @param ref
  31359. */
  31360. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31361. /**
  31362. * Computes the required SubMeshes according the materials assigned to the particles.
  31363. * @returns the solid particle system.
  31364. * Does nothing if called before the SPS mesh is built.
  31365. */
  31366. computeSubMeshes(): SolidParticleSystem;
  31367. /**
  31368. * Sorts the solid particles by material when MultiMaterial is enabled.
  31369. * Updates the indices32 array.
  31370. * Updates the indicesByMaterial array.
  31371. * Updates the mesh indices array.
  31372. * @returns the SPS
  31373. * @hidden
  31374. */
  31375. private _sortParticlesByMaterial;
  31376. /**
  31377. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31378. * @hidden
  31379. */
  31380. private _setMaterialIndexesById;
  31381. /**
  31382. * Returns an array with unique values of Materials from the passed array
  31383. * @param array the material array to be checked and filtered
  31384. * @hidden
  31385. */
  31386. private _filterUniqueMaterialId;
  31387. /**
  31388. * Sets a new Standard Material as _defaultMaterial if not already set.
  31389. * @hidden
  31390. */
  31391. private _setDefaultMaterial;
  31392. /**
  31393. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31394. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31395. * @returns the SPS.
  31396. */
  31397. refreshVisibleSize(): SolidParticleSystem;
  31398. /**
  31399. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31400. * @param size the size (float) of the visibility box
  31401. * note : this doesn't lock the SPS mesh bounding box.
  31402. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31403. */
  31404. setVisibilityBox(size: number): void;
  31405. /**
  31406. * Gets whether the SPS as always visible or not
  31407. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31408. */
  31409. get isAlwaysVisible(): boolean;
  31410. /**
  31411. * Sets the SPS as always visible or not
  31412. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31413. */
  31414. set isAlwaysVisible(val: boolean);
  31415. /**
  31416. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31417. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31418. */
  31419. set isVisibilityBoxLocked(val: boolean);
  31420. /**
  31421. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31422. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31423. */
  31424. get isVisibilityBoxLocked(): boolean;
  31425. /**
  31426. * Tells to `setParticles()` to compute the particle rotations or not.
  31427. * Default value : true. The SPS is faster when it's set to false.
  31428. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31429. */
  31430. set computeParticleRotation(val: boolean);
  31431. /**
  31432. * Tells to `setParticles()` to compute the particle colors or not.
  31433. * Default value : true. The SPS is faster when it's set to false.
  31434. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31435. */
  31436. set computeParticleColor(val: boolean);
  31437. set computeParticleTexture(val: boolean);
  31438. /**
  31439. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31440. * Default value : false. The SPS is faster when it's set to false.
  31441. * Note : the particle custom vertex positions aren't stored values.
  31442. */
  31443. set computeParticleVertex(val: boolean);
  31444. /**
  31445. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31446. */
  31447. set computeBoundingBox(val: boolean);
  31448. /**
  31449. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31450. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31451. * Default : `true`
  31452. */
  31453. set depthSortParticles(val: boolean);
  31454. /**
  31455. * Gets if `setParticles()` computes the particle rotations or not.
  31456. * Default value : true. The SPS is faster when it's set to false.
  31457. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31458. */
  31459. get computeParticleRotation(): boolean;
  31460. /**
  31461. * Gets if `setParticles()` computes the particle colors or not.
  31462. * Default value : true. The SPS is faster when it's set to false.
  31463. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31464. */
  31465. get computeParticleColor(): boolean;
  31466. /**
  31467. * Gets if `setParticles()` computes the particle textures or not.
  31468. * Default value : true. The SPS is faster when it's set to false.
  31469. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31470. */
  31471. get computeParticleTexture(): boolean;
  31472. /**
  31473. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31474. * Default value : false. The SPS is faster when it's set to false.
  31475. * Note : the particle custom vertex positions aren't stored values.
  31476. */
  31477. get computeParticleVertex(): boolean;
  31478. /**
  31479. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31480. */
  31481. get computeBoundingBox(): boolean;
  31482. /**
  31483. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31484. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31485. * Default : `true`
  31486. */
  31487. get depthSortParticles(): boolean;
  31488. /**
  31489. * Gets if the SPS is created as expandable at construction time.
  31490. * Default : `false`
  31491. */
  31492. get expandable(): boolean;
  31493. /**
  31494. * Gets if the SPS supports the Multi Materials
  31495. */
  31496. get multimaterialEnabled(): boolean;
  31497. /**
  31498. * Gets if the SPS uses the model materials for its own multimaterial.
  31499. */
  31500. get useModelMaterial(): boolean;
  31501. /**
  31502. * The SPS used material array.
  31503. */
  31504. get materials(): Material[];
  31505. /**
  31506. * Sets the SPS MultiMaterial from the passed materials.
  31507. * Note : the passed array is internally copied and not used then by reference.
  31508. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31509. */
  31510. setMultiMaterial(materials: Material[]): void;
  31511. /**
  31512. * The SPS computed multimaterial object
  31513. */
  31514. get multimaterial(): MultiMaterial;
  31515. set multimaterial(mm: MultiMaterial);
  31516. /**
  31517. * If the subMeshes must be updated on the next call to setParticles()
  31518. */
  31519. get autoUpdateSubMeshes(): boolean;
  31520. set autoUpdateSubMeshes(val: boolean);
  31521. /**
  31522. * This function does nothing. It may be overwritten to set all the particle first values.
  31523. * The SPS doesn't call this function, you may have to call it by your own.
  31524. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31525. */
  31526. initParticles(): void;
  31527. /**
  31528. * This function does nothing. It may be overwritten to recycle a particle.
  31529. * The SPS doesn't call this function, you may have to call it by your own.
  31530. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31531. * @param particle The particle to recycle
  31532. * @returns the recycled particle
  31533. */
  31534. recycleParticle(particle: SolidParticle): SolidParticle;
  31535. /**
  31536. * Updates a particle : this function should be overwritten by the user.
  31537. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31538. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31539. * @example : just set a particle position or velocity and recycle conditions
  31540. * @param particle The particle to update
  31541. * @returns the updated particle
  31542. */
  31543. updateParticle(particle: SolidParticle): SolidParticle;
  31544. /**
  31545. * Updates a vertex of a particle : it can be overwritten by the user.
  31546. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31547. * @param particle the current particle
  31548. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31549. * @param pt the index of the current vertex in the particle shape
  31550. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31551. * @example : just set a vertex particle position or color
  31552. * @returns the sps
  31553. */
  31554. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31555. /**
  31556. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31557. * This does nothing and may be overwritten by the user.
  31558. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31559. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31560. * @param update the boolean update value actually passed to setParticles()
  31561. */
  31562. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31563. /**
  31564. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31565. * This will be passed three parameters.
  31566. * This does nothing and may be overwritten by the user.
  31567. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31568. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31569. * @param update the boolean update value actually passed to setParticles()
  31570. */
  31571. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31572. }
  31573. }
  31574. declare module BABYLON {
  31575. /**
  31576. * Represents one particle of a solid particle system.
  31577. */
  31578. export class SolidParticle {
  31579. /**
  31580. * particle global index
  31581. */
  31582. idx: number;
  31583. /**
  31584. * particle identifier
  31585. */
  31586. id: number;
  31587. /**
  31588. * The color of the particle
  31589. */
  31590. color: Nullable<Color4>;
  31591. /**
  31592. * The world space position of the particle.
  31593. */
  31594. position: Vector3;
  31595. /**
  31596. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31597. */
  31598. rotation: Vector3;
  31599. /**
  31600. * The world space rotation quaternion of the particle.
  31601. */
  31602. rotationQuaternion: Nullable<Quaternion>;
  31603. /**
  31604. * The scaling of the particle.
  31605. */
  31606. scaling: Vector3;
  31607. /**
  31608. * The uvs of the particle.
  31609. */
  31610. uvs: Vector4;
  31611. /**
  31612. * The current speed of the particle.
  31613. */
  31614. velocity: Vector3;
  31615. /**
  31616. * The pivot point in the particle local space.
  31617. */
  31618. pivot: Vector3;
  31619. /**
  31620. * Must the particle be translated from its pivot point in its local space ?
  31621. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31622. * Default : false
  31623. */
  31624. translateFromPivot: boolean;
  31625. /**
  31626. * Is the particle active or not ?
  31627. */
  31628. alive: boolean;
  31629. /**
  31630. * Is the particle visible or not ?
  31631. */
  31632. isVisible: boolean;
  31633. /**
  31634. * Index of this particle in the global "positions" array (Internal use)
  31635. * @hidden
  31636. */
  31637. _pos: number;
  31638. /**
  31639. * @hidden Index of this particle in the global "indices" array (Internal use)
  31640. */
  31641. _ind: number;
  31642. /**
  31643. * @hidden ModelShape of this particle (Internal use)
  31644. */
  31645. _model: ModelShape;
  31646. /**
  31647. * ModelShape id of this particle
  31648. */
  31649. shapeId: number;
  31650. /**
  31651. * Index of the particle in its shape id
  31652. */
  31653. idxInShape: number;
  31654. /**
  31655. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31656. */
  31657. _modelBoundingInfo: BoundingInfo;
  31658. /**
  31659. * @hidden Particle BoundingInfo object (Internal use)
  31660. */
  31661. _boundingInfo: BoundingInfo;
  31662. /**
  31663. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31664. */
  31665. _sps: SolidParticleSystem;
  31666. /**
  31667. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31668. */
  31669. _stillInvisible: boolean;
  31670. /**
  31671. * @hidden Last computed particle rotation matrix
  31672. */
  31673. _rotationMatrix: number[];
  31674. /**
  31675. * Parent particle Id, if any.
  31676. * Default null.
  31677. */
  31678. parentId: Nullable<number>;
  31679. /**
  31680. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31681. */
  31682. materialIndex: Nullable<number>;
  31683. /**
  31684. * Custom object or properties.
  31685. */
  31686. props: Nullable<any>;
  31687. /**
  31688. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31689. * The possible values are :
  31690. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31691. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31694. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31695. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31696. * */
  31697. cullingStrategy: number;
  31698. /**
  31699. * @hidden Internal global position in the SPS.
  31700. */
  31701. _globalPosition: Vector3;
  31702. /**
  31703. * Creates a Solid Particle object.
  31704. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31705. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31706. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31707. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31708. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31709. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31710. * @param shapeId (integer) is the model shape identifier in the SPS.
  31711. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31712. * @param sps defines the sps it is associated to
  31713. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31714. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31715. */
  31716. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31717. /**
  31718. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31719. * @param target the particle target
  31720. * @returns the current particle
  31721. */
  31722. copyToRef(target: SolidParticle): SolidParticle;
  31723. /**
  31724. * Legacy support, changed scale to scaling
  31725. */
  31726. get scale(): Vector3;
  31727. /**
  31728. * Legacy support, changed scale to scaling
  31729. */
  31730. set scale(scale: Vector3);
  31731. /**
  31732. * Legacy support, changed quaternion to rotationQuaternion
  31733. */
  31734. get quaternion(): Nullable<Quaternion>;
  31735. /**
  31736. * Legacy support, changed quaternion to rotationQuaternion
  31737. */
  31738. set quaternion(q: Nullable<Quaternion>);
  31739. /**
  31740. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31741. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31742. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31743. * @returns true if it intersects
  31744. */
  31745. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31746. /**
  31747. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31748. * A particle is in the frustum if its bounding box intersects the frustum
  31749. * @param frustumPlanes defines the frustum to test
  31750. * @returns true if the particle is in the frustum planes
  31751. */
  31752. isInFrustum(frustumPlanes: Plane[]): boolean;
  31753. /**
  31754. * get the rotation matrix of the particle
  31755. * @hidden
  31756. */
  31757. getRotationMatrix(m: Matrix): void;
  31758. }
  31759. /**
  31760. * Represents the shape of the model used by one particle of a solid particle system.
  31761. * SPS internal tool, don't use it manually.
  31762. */
  31763. export class ModelShape {
  31764. /**
  31765. * The shape id
  31766. * @hidden
  31767. */
  31768. shapeID: number;
  31769. /**
  31770. * flat array of model positions (internal use)
  31771. * @hidden
  31772. */
  31773. _shape: Vector3[];
  31774. /**
  31775. * flat array of model UVs (internal use)
  31776. * @hidden
  31777. */
  31778. _shapeUV: number[];
  31779. /**
  31780. * color array of the model
  31781. * @hidden
  31782. */
  31783. _shapeColors: number[];
  31784. /**
  31785. * indices array of the model
  31786. * @hidden
  31787. */
  31788. _indices: number[];
  31789. /**
  31790. * normals array of the model
  31791. * @hidden
  31792. */
  31793. _normals: number[];
  31794. /**
  31795. * length of the shape in the model indices array (internal use)
  31796. * @hidden
  31797. */
  31798. _indicesLength: number;
  31799. /**
  31800. * Custom position function (internal use)
  31801. * @hidden
  31802. */
  31803. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31804. /**
  31805. * Custom vertex function (internal use)
  31806. * @hidden
  31807. */
  31808. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31809. /**
  31810. * Model material (internal use)
  31811. * @hidden
  31812. */
  31813. _material: Nullable<Material>;
  31814. /**
  31815. * 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.
  31816. * SPS internal tool, don't use it manually.
  31817. * @hidden
  31818. */
  31819. 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>);
  31820. }
  31821. /**
  31822. * Represents a Depth Sorted Particle in the solid particle system.
  31823. * @hidden
  31824. */
  31825. export class DepthSortedParticle {
  31826. /**
  31827. * Particle index
  31828. */
  31829. idx: number;
  31830. /**
  31831. * Index of the particle in the "indices" array
  31832. */
  31833. ind: number;
  31834. /**
  31835. * Length of the particle shape in the "indices" array
  31836. */
  31837. indicesLength: number;
  31838. /**
  31839. * Squared distance from the particle to the camera
  31840. */
  31841. sqDistance: number;
  31842. /**
  31843. * Material index when used with MultiMaterials
  31844. */
  31845. materialIndex: number;
  31846. /**
  31847. * Creates a new sorted particle
  31848. * @param materialIndex
  31849. */
  31850. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31851. }
  31852. /**
  31853. * Represents a solid particle vertex
  31854. */
  31855. export class SolidParticleVertex {
  31856. /**
  31857. * Vertex position
  31858. */
  31859. position: Vector3;
  31860. /**
  31861. * Vertex color
  31862. */
  31863. color: Color4;
  31864. /**
  31865. * Vertex UV
  31866. */
  31867. uv: Vector2;
  31868. /**
  31869. * Creates a new solid particle vertex
  31870. */
  31871. constructor();
  31872. /** Vertex x coordinate */
  31873. get x(): number;
  31874. set x(val: number);
  31875. /** Vertex y coordinate */
  31876. get y(): number;
  31877. set y(val: number);
  31878. /** Vertex z coordinate */
  31879. get z(): number;
  31880. set z(val: number);
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /**
  31885. * @hidden
  31886. */
  31887. export class _MeshCollisionData {
  31888. _checkCollisions: boolean;
  31889. _collisionMask: number;
  31890. _collisionGroup: number;
  31891. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31892. _collider: Nullable<Collider>;
  31893. _oldPositionForCollisions: Vector3;
  31894. _diffPositionForCollisions: Vector3;
  31895. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31896. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31897. }
  31898. }
  31899. declare module BABYLON {
  31900. /** @hidden */
  31901. class _FacetDataStorage {
  31902. facetPositions: Vector3[];
  31903. facetNormals: Vector3[];
  31904. facetPartitioning: number[][];
  31905. facetNb: number;
  31906. partitioningSubdivisions: number;
  31907. partitioningBBoxRatio: number;
  31908. facetDataEnabled: boolean;
  31909. facetParameters: any;
  31910. bbSize: Vector3;
  31911. subDiv: {
  31912. max: number;
  31913. X: number;
  31914. Y: number;
  31915. Z: number;
  31916. };
  31917. facetDepthSort: boolean;
  31918. facetDepthSortEnabled: boolean;
  31919. depthSortedIndices: IndicesArray;
  31920. depthSortedFacets: {
  31921. ind: number;
  31922. sqDistance: number;
  31923. }[];
  31924. facetDepthSortFunction: (f1: {
  31925. ind: number;
  31926. sqDistance: number;
  31927. }, f2: {
  31928. ind: number;
  31929. sqDistance: number;
  31930. }) => number;
  31931. facetDepthSortFrom: Vector3;
  31932. facetDepthSortOrigin: Vector3;
  31933. invertedMatrix: Matrix;
  31934. }
  31935. /**
  31936. * @hidden
  31937. **/
  31938. class _InternalAbstractMeshDataInfo {
  31939. _hasVertexAlpha: boolean;
  31940. _useVertexColors: boolean;
  31941. _numBoneInfluencers: number;
  31942. _applyFog: boolean;
  31943. _receiveShadows: boolean;
  31944. _facetData: _FacetDataStorage;
  31945. _visibility: number;
  31946. _skeleton: Nullable<Skeleton>;
  31947. _layerMask: number;
  31948. _computeBonesUsingShaders: boolean;
  31949. _isActive: boolean;
  31950. _onlyForInstances: boolean;
  31951. _isActiveIntermediate: boolean;
  31952. _onlyForInstancesIntermediate: boolean;
  31953. _actAsRegularMesh: boolean;
  31954. }
  31955. /**
  31956. * Class used to store all common mesh properties
  31957. */
  31958. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31959. /** No occlusion */
  31960. static OCCLUSION_TYPE_NONE: number;
  31961. /** Occlusion set to optimisitic */
  31962. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31963. /** Occlusion set to strict */
  31964. static OCCLUSION_TYPE_STRICT: number;
  31965. /** Use an accurante occlusion algorithm */
  31966. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31967. /** Use a conservative occlusion algorithm */
  31968. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31969. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31970. * Test order :
  31971. * Is the bounding sphere outside the frustum ?
  31972. * If not, are the bounding box vertices outside the frustum ?
  31973. * It not, then the cullable object is in the frustum.
  31974. */
  31975. static readonly CULLINGSTRATEGY_STANDARD: number;
  31976. /** Culling strategy : Bounding Sphere Only.
  31977. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31978. * It's also less accurate than the standard because some not visible objects can still be selected.
  31979. * Test : is the bounding sphere outside the frustum ?
  31980. * If not, then the cullable object is in the frustum.
  31981. */
  31982. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31983. /** Culling strategy : Optimistic Inclusion.
  31984. * This in an inclusion test first, then the standard exclusion test.
  31985. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31986. * 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.
  31987. * Anyway, it's as accurate as the standard strategy.
  31988. * Test :
  31989. * Is the cullable object bounding sphere center in the frustum ?
  31990. * If not, apply the default culling strategy.
  31991. */
  31992. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31993. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31994. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31995. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31996. * 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.
  31997. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31998. * Test :
  31999. * Is the cullable object bounding sphere center in the frustum ?
  32000. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32001. */
  32002. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32003. /**
  32004. * No billboard
  32005. */
  32006. static get BILLBOARDMODE_NONE(): number;
  32007. /** Billboard on X axis */
  32008. static get BILLBOARDMODE_X(): number;
  32009. /** Billboard on Y axis */
  32010. static get BILLBOARDMODE_Y(): number;
  32011. /** Billboard on Z axis */
  32012. static get BILLBOARDMODE_Z(): number;
  32013. /** Billboard on all axes */
  32014. static get BILLBOARDMODE_ALL(): number;
  32015. /** Billboard on using position instead of orientation */
  32016. static get BILLBOARDMODE_USE_POSITION(): number;
  32017. /** @hidden */
  32018. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32019. /**
  32020. * The culling strategy to use to check whether the mesh must be rendered or not.
  32021. * This value can be changed at any time and will be used on the next render mesh selection.
  32022. * The possible values are :
  32023. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32024. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32025. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32027. * Please read each static variable documentation to get details about the culling process.
  32028. * */
  32029. cullingStrategy: number;
  32030. /**
  32031. * Gets the number of facets in the mesh
  32032. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32033. */
  32034. get facetNb(): number;
  32035. /**
  32036. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32037. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32038. */
  32039. get partitioningSubdivisions(): number;
  32040. set partitioningSubdivisions(nb: number);
  32041. /**
  32042. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32043. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32044. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32045. */
  32046. get partitioningBBoxRatio(): number;
  32047. set partitioningBBoxRatio(ratio: number);
  32048. /**
  32049. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32050. * Works only for updatable meshes.
  32051. * Doesn't work with multi-materials
  32052. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32053. */
  32054. get mustDepthSortFacets(): boolean;
  32055. set mustDepthSortFacets(sort: boolean);
  32056. /**
  32057. * The location (Vector3) where the facet depth sort must be computed from.
  32058. * By default, the active camera position.
  32059. * Used only when facet depth sort is enabled
  32060. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32061. */
  32062. get facetDepthSortFrom(): Vector3;
  32063. set facetDepthSortFrom(location: Vector3);
  32064. /**
  32065. * gets a boolean indicating if facetData is enabled
  32066. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32067. */
  32068. get isFacetDataEnabled(): boolean;
  32069. /** @hidden */
  32070. _updateNonUniformScalingState(value: boolean): boolean;
  32071. /**
  32072. * An event triggered when this mesh collides with another one
  32073. */
  32074. onCollideObservable: Observable<AbstractMesh>;
  32075. /** Set a function to call when this mesh collides with another one */
  32076. set onCollide(callback: () => void);
  32077. /**
  32078. * An event triggered when the collision's position changes
  32079. */
  32080. onCollisionPositionChangeObservable: Observable<Vector3>;
  32081. /** Set a function to call when the collision's position changes */
  32082. set onCollisionPositionChange(callback: () => void);
  32083. /**
  32084. * An event triggered when material is changed
  32085. */
  32086. onMaterialChangedObservable: Observable<AbstractMesh>;
  32087. /**
  32088. * Gets or sets the orientation for POV movement & rotation
  32089. */
  32090. definedFacingForward: boolean;
  32091. /** @hidden */
  32092. _occlusionQuery: Nullable<WebGLQuery>;
  32093. /** @hidden */
  32094. _renderingGroup: Nullable<RenderingGroup>;
  32095. /**
  32096. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32097. */
  32098. get visibility(): number;
  32099. /**
  32100. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32101. */
  32102. set visibility(value: number);
  32103. /** Gets or sets the alpha index used to sort transparent meshes
  32104. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32105. */
  32106. alphaIndex: number;
  32107. /**
  32108. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32109. */
  32110. isVisible: boolean;
  32111. /**
  32112. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32113. */
  32114. isPickable: boolean;
  32115. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32116. showSubMeshesBoundingBox: boolean;
  32117. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32118. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32119. */
  32120. isBlocker: boolean;
  32121. /**
  32122. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32123. */
  32124. enablePointerMoveEvents: boolean;
  32125. /**
  32126. * Specifies the rendering group id for this mesh (0 by default)
  32127. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32128. */
  32129. renderingGroupId: number;
  32130. private _material;
  32131. /** Gets or sets current material */
  32132. get material(): Nullable<Material>;
  32133. set material(value: Nullable<Material>);
  32134. /**
  32135. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32136. * @see https://doc.babylonjs.com/babylon101/shadows
  32137. */
  32138. get receiveShadows(): boolean;
  32139. set receiveShadows(value: boolean);
  32140. /** Defines color to use when rendering outline */
  32141. outlineColor: Color3;
  32142. /** Define width to use when rendering outline */
  32143. outlineWidth: number;
  32144. /** Defines color to use when rendering overlay */
  32145. overlayColor: Color3;
  32146. /** Defines alpha to use when rendering overlay */
  32147. overlayAlpha: number;
  32148. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32149. get hasVertexAlpha(): boolean;
  32150. set hasVertexAlpha(value: boolean);
  32151. /** 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) */
  32152. get useVertexColors(): boolean;
  32153. set useVertexColors(value: boolean);
  32154. /**
  32155. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32156. */
  32157. get computeBonesUsingShaders(): boolean;
  32158. set computeBonesUsingShaders(value: boolean);
  32159. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32160. get numBoneInfluencers(): number;
  32161. set numBoneInfluencers(value: number);
  32162. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32163. get applyFog(): boolean;
  32164. set applyFog(value: boolean);
  32165. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32166. useOctreeForRenderingSelection: boolean;
  32167. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32168. useOctreeForPicking: boolean;
  32169. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32170. useOctreeForCollisions: boolean;
  32171. /**
  32172. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32173. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32174. */
  32175. get layerMask(): number;
  32176. set layerMask(value: number);
  32177. /**
  32178. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32179. */
  32180. alwaysSelectAsActiveMesh: boolean;
  32181. /**
  32182. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32183. */
  32184. doNotSyncBoundingInfo: boolean;
  32185. /**
  32186. * Gets or sets the current action manager
  32187. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32188. */
  32189. actionManager: Nullable<AbstractActionManager>;
  32190. private _meshCollisionData;
  32191. /**
  32192. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32193. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32194. */
  32195. ellipsoid: Vector3;
  32196. /**
  32197. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32198. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32199. */
  32200. ellipsoidOffset: Vector3;
  32201. /**
  32202. * Gets or sets a collision mask used to mask collisions (default is -1).
  32203. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32204. */
  32205. get collisionMask(): number;
  32206. set collisionMask(mask: number);
  32207. /**
  32208. * Gets or sets the current collision group mask (-1 by default).
  32209. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32210. */
  32211. get collisionGroup(): number;
  32212. set collisionGroup(mask: number);
  32213. /**
  32214. * Gets or sets current surrounding meshes (null by default).
  32215. *
  32216. * By default collision detection is tested against every mesh in the scene.
  32217. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32218. * meshes will be tested for the collision.
  32219. *
  32220. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32221. */
  32222. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32223. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32224. /**
  32225. * Defines edge width used when edgesRenderer is enabled
  32226. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32227. */
  32228. edgesWidth: number;
  32229. /**
  32230. * Defines edge color used when edgesRenderer is enabled
  32231. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32232. */
  32233. edgesColor: Color4;
  32234. /** @hidden */
  32235. _edgesRenderer: Nullable<IEdgesRenderer>;
  32236. /** @hidden */
  32237. _masterMesh: Nullable<AbstractMesh>;
  32238. /** @hidden */
  32239. _boundingInfo: Nullable<BoundingInfo>;
  32240. /** @hidden */
  32241. _renderId: number;
  32242. /**
  32243. * Gets or sets the list of subMeshes
  32244. * @see https://doc.babylonjs.com/how_to/multi_materials
  32245. */
  32246. subMeshes: SubMesh[];
  32247. /** @hidden */
  32248. _intersectionsInProgress: AbstractMesh[];
  32249. /** @hidden */
  32250. _unIndexed: boolean;
  32251. /** @hidden */
  32252. _lightSources: Light[];
  32253. /** Gets the list of lights affecting that mesh */
  32254. get lightSources(): Light[];
  32255. /** @hidden */
  32256. get _positions(): Nullable<Vector3[]>;
  32257. /** @hidden */
  32258. _waitingData: {
  32259. lods: Nullable<any>;
  32260. actions: Nullable<any>;
  32261. freezeWorldMatrix: Nullable<boolean>;
  32262. };
  32263. /** @hidden */
  32264. _bonesTransformMatrices: Nullable<Float32Array>;
  32265. /** @hidden */
  32266. _transformMatrixTexture: Nullable<RawTexture>;
  32267. /**
  32268. * Gets or sets a skeleton to apply skining transformations
  32269. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32270. */
  32271. set skeleton(value: Nullable<Skeleton>);
  32272. get skeleton(): Nullable<Skeleton>;
  32273. /**
  32274. * An event triggered when the mesh is rebuilt.
  32275. */
  32276. onRebuildObservable: Observable<AbstractMesh>;
  32277. /**
  32278. * Creates a new AbstractMesh
  32279. * @param name defines the name of the mesh
  32280. * @param scene defines the hosting scene
  32281. */
  32282. constructor(name: string, scene?: Nullable<Scene>);
  32283. /**
  32284. * Returns the string "AbstractMesh"
  32285. * @returns "AbstractMesh"
  32286. */
  32287. getClassName(): string;
  32288. /**
  32289. * Gets a string representation of the current mesh
  32290. * @param fullDetails defines a boolean indicating if full details must be included
  32291. * @returns a string representation of the current mesh
  32292. */
  32293. toString(fullDetails?: boolean): string;
  32294. /**
  32295. * @hidden
  32296. */
  32297. protected _getEffectiveParent(): Nullable<Node>;
  32298. /** @hidden */
  32299. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32300. /** @hidden */
  32301. _rebuild(): void;
  32302. /** @hidden */
  32303. _resyncLightSources(): void;
  32304. /** @hidden */
  32305. _resyncLightSource(light: Light): void;
  32306. /** @hidden */
  32307. _unBindEffect(): void;
  32308. /** @hidden */
  32309. _removeLightSource(light: Light, dispose: boolean): void;
  32310. private _markSubMeshesAsDirty;
  32311. /** @hidden */
  32312. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32313. /** @hidden */
  32314. _markSubMeshesAsAttributesDirty(): void;
  32315. /** @hidden */
  32316. _markSubMeshesAsMiscDirty(): void;
  32317. /**
  32318. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32319. */
  32320. get scaling(): Vector3;
  32321. set scaling(newScaling: Vector3);
  32322. /**
  32323. * Returns true if the mesh is blocked. Implemented by child classes
  32324. */
  32325. get isBlocked(): boolean;
  32326. /**
  32327. * Returns the mesh itself by default. Implemented by child classes
  32328. * @param camera defines the camera to use to pick the right LOD level
  32329. * @returns the currentAbstractMesh
  32330. */
  32331. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32332. /**
  32333. * Returns 0 by default. Implemented by child classes
  32334. * @returns an integer
  32335. */
  32336. getTotalVertices(): number;
  32337. /**
  32338. * Returns a positive integer : the total number of indices in this mesh geometry.
  32339. * @returns the numner of indices or zero if the mesh has no geometry.
  32340. */
  32341. getTotalIndices(): number;
  32342. /**
  32343. * Returns null by default. Implemented by child classes
  32344. * @returns null
  32345. */
  32346. getIndices(): Nullable<IndicesArray>;
  32347. /**
  32348. * Returns the array of the requested vertex data kind. Implemented by child classes
  32349. * @param kind defines the vertex data kind to use
  32350. * @returns null
  32351. */
  32352. getVerticesData(kind: string): Nullable<FloatArray>;
  32353. /**
  32354. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32355. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32356. * Note that a new underlying VertexBuffer object is created each call.
  32357. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32358. * @param kind defines vertex data kind:
  32359. * * VertexBuffer.PositionKind
  32360. * * VertexBuffer.UVKind
  32361. * * VertexBuffer.UV2Kind
  32362. * * VertexBuffer.UV3Kind
  32363. * * VertexBuffer.UV4Kind
  32364. * * VertexBuffer.UV5Kind
  32365. * * VertexBuffer.UV6Kind
  32366. * * VertexBuffer.ColorKind
  32367. * * VertexBuffer.MatricesIndicesKind
  32368. * * VertexBuffer.MatricesIndicesExtraKind
  32369. * * VertexBuffer.MatricesWeightsKind
  32370. * * VertexBuffer.MatricesWeightsExtraKind
  32371. * @param data defines the data source
  32372. * @param updatable defines if the data must be flagged as updatable (or static)
  32373. * @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
  32374. * @returns the current mesh
  32375. */
  32376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32377. /**
  32378. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32379. * If the mesh has no geometry, it is simply returned as it is.
  32380. * @param kind defines vertex data kind:
  32381. * * VertexBuffer.PositionKind
  32382. * * VertexBuffer.UVKind
  32383. * * VertexBuffer.UV2Kind
  32384. * * VertexBuffer.UV3Kind
  32385. * * VertexBuffer.UV4Kind
  32386. * * VertexBuffer.UV5Kind
  32387. * * VertexBuffer.UV6Kind
  32388. * * VertexBuffer.ColorKind
  32389. * * VertexBuffer.MatricesIndicesKind
  32390. * * VertexBuffer.MatricesIndicesExtraKind
  32391. * * VertexBuffer.MatricesWeightsKind
  32392. * * VertexBuffer.MatricesWeightsExtraKind
  32393. * @param data defines the data source
  32394. * @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
  32395. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32396. * @returns the current mesh
  32397. */
  32398. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32399. /**
  32400. * Sets the mesh indices,
  32401. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32402. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32403. * @param totalVertices Defines the total number of vertices
  32404. * @returns the current mesh
  32405. */
  32406. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32407. /**
  32408. * Gets a boolean indicating if specific vertex data is present
  32409. * @param kind defines the vertex data kind to use
  32410. * @returns true is data kind is present
  32411. */
  32412. isVerticesDataPresent(kind: string): boolean;
  32413. /**
  32414. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32415. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32416. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32417. * @returns a BoundingInfo
  32418. */
  32419. getBoundingInfo(): BoundingInfo;
  32420. /**
  32421. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32422. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32423. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32424. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32425. * @returns the current mesh
  32426. */
  32427. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32428. /**
  32429. * Overwrite the current bounding info
  32430. * @param boundingInfo defines the new bounding info
  32431. * @returns the current mesh
  32432. */
  32433. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32434. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32435. get useBones(): boolean;
  32436. /** @hidden */
  32437. _preActivate(): void;
  32438. /** @hidden */
  32439. _preActivateForIntermediateRendering(renderId: number): void;
  32440. /** @hidden */
  32441. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32442. /** @hidden */
  32443. _postActivate(): void;
  32444. /** @hidden */
  32445. _freeze(): void;
  32446. /** @hidden */
  32447. _unFreeze(): void;
  32448. /**
  32449. * Gets the current world matrix
  32450. * @returns a Matrix
  32451. */
  32452. getWorldMatrix(): Matrix;
  32453. /** @hidden */
  32454. _getWorldMatrixDeterminant(): number;
  32455. /**
  32456. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32457. */
  32458. get isAnInstance(): boolean;
  32459. /**
  32460. * Gets a boolean indicating if this mesh has instances
  32461. */
  32462. get hasInstances(): boolean;
  32463. /**
  32464. * Gets a boolean indicating if this mesh has thin instances
  32465. */
  32466. get hasThinInstances(): boolean;
  32467. /**
  32468. * Perform relative position change from the point of view of behind the front of the mesh.
  32469. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32470. * Supports definition of mesh facing forward or backward
  32471. * @param amountRight defines the distance on the right axis
  32472. * @param amountUp defines the distance on the up axis
  32473. * @param amountForward defines the distance on the forward axis
  32474. * @returns the current mesh
  32475. */
  32476. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32477. /**
  32478. * Calculate relative position change from the point of view of behind the front of the mesh.
  32479. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32480. * Supports definition of mesh facing forward or backward
  32481. * @param amountRight defines the distance on the right axis
  32482. * @param amountUp defines the distance on the up axis
  32483. * @param amountForward defines the distance on the forward axis
  32484. * @returns the new displacement vector
  32485. */
  32486. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32487. /**
  32488. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32489. * Supports definition of mesh facing forward or backward
  32490. * @param flipBack defines the flip
  32491. * @param twirlClockwise defines the twirl
  32492. * @param tiltRight defines the tilt
  32493. * @returns the current mesh
  32494. */
  32495. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32496. /**
  32497. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32498. * Supports definition of mesh facing forward or backward.
  32499. * @param flipBack defines the flip
  32500. * @param twirlClockwise defines the twirl
  32501. * @param tiltRight defines the tilt
  32502. * @returns the new rotation vector
  32503. */
  32504. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32505. /**
  32506. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32507. * This means the mesh underlying bounding box and sphere are recomputed.
  32508. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32509. * @returns the current mesh
  32510. */
  32511. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32512. /** @hidden */
  32513. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32514. /** @hidden */
  32515. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32516. /** @hidden */
  32517. _updateBoundingInfo(): AbstractMesh;
  32518. /** @hidden */
  32519. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32520. /** @hidden */
  32521. protected _afterComputeWorldMatrix(): void;
  32522. /** @hidden */
  32523. get _effectiveMesh(): AbstractMesh;
  32524. /**
  32525. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32526. * A mesh is in the frustum if its bounding box intersects the frustum
  32527. * @param frustumPlanes defines the frustum to test
  32528. * @returns true if the mesh is in the frustum planes
  32529. */
  32530. isInFrustum(frustumPlanes: Plane[]): boolean;
  32531. /**
  32532. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32533. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32534. * @param frustumPlanes defines the frustum to test
  32535. * @returns true if the mesh is completely in the frustum planes
  32536. */
  32537. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32538. /**
  32539. * True if the mesh intersects another mesh or a SolidParticle object
  32540. * @param mesh defines a target mesh or SolidParticle to test
  32541. * @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)
  32542. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32543. * @returns true if there is an intersection
  32544. */
  32545. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32546. /**
  32547. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32548. * @param point defines the point to test
  32549. * @returns true if there is an intersection
  32550. */
  32551. intersectsPoint(point: Vector3): boolean;
  32552. /**
  32553. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32554. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32555. */
  32556. get checkCollisions(): boolean;
  32557. set checkCollisions(collisionEnabled: boolean);
  32558. /**
  32559. * Gets Collider object used to compute collisions (not physics)
  32560. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32561. */
  32562. get collider(): Nullable<Collider>;
  32563. /**
  32564. * Move the mesh using collision engine
  32565. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32566. * @param displacement defines the requested displacement vector
  32567. * @returns the current mesh
  32568. */
  32569. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32570. private _onCollisionPositionChange;
  32571. /** @hidden */
  32572. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32573. /** @hidden */
  32574. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32575. /** @hidden */
  32576. _checkCollision(collider: Collider): AbstractMesh;
  32577. /** @hidden */
  32578. _generatePointsArray(): boolean;
  32579. /**
  32580. * Checks if the passed Ray intersects with the mesh
  32581. * @param ray defines the ray to use
  32582. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32583. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32584. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32585. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32586. * @returns the picking info
  32587. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32588. */
  32589. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32590. /**
  32591. * Clones the current mesh
  32592. * @param name defines the mesh name
  32593. * @param newParent defines the new mesh parent
  32594. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32595. * @returns the new mesh
  32596. */
  32597. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32598. /**
  32599. * Disposes all the submeshes of the current meshnp
  32600. * @returns the current mesh
  32601. */
  32602. releaseSubMeshes(): AbstractMesh;
  32603. /**
  32604. * Releases resources associated with this abstract mesh.
  32605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32607. */
  32608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32609. /**
  32610. * Adds the passed mesh as a child to the current mesh
  32611. * @param mesh defines the child mesh
  32612. * @returns the current mesh
  32613. */
  32614. addChild(mesh: AbstractMesh): AbstractMesh;
  32615. /**
  32616. * Removes the passed mesh from the current mesh children list
  32617. * @param mesh defines the child mesh
  32618. * @returns the current mesh
  32619. */
  32620. removeChild(mesh: AbstractMesh): AbstractMesh;
  32621. /** @hidden */
  32622. private _initFacetData;
  32623. /**
  32624. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32625. * This method can be called within the render loop.
  32626. * 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
  32627. * @returns the current mesh
  32628. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32629. */
  32630. updateFacetData(): AbstractMesh;
  32631. /**
  32632. * Returns the facetLocalNormals array.
  32633. * The normals are expressed in the mesh local spac
  32634. * @returns an array of Vector3
  32635. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32636. */
  32637. getFacetLocalNormals(): Vector3[];
  32638. /**
  32639. * Returns the facetLocalPositions array.
  32640. * The facet positions are expressed in the mesh local space
  32641. * @returns an array of Vector3
  32642. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32643. */
  32644. getFacetLocalPositions(): Vector3[];
  32645. /**
  32646. * Returns the facetLocalPartioning array
  32647. * @returns an array of array of numbers
  32648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32649. */
  32650. getFacetLocalPartitioning(): number[][];
  32651. /**
  32652. * Returns the i-th facet position in the world system.
  32653. * This method allocates a new Vector3 per call
  32654. * @param i defines the facet index
  32655. * @returns a new Vector3
  32656. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32657. */
  32658. getFacetPosition(i: number): Vector3;
  32659. /**
  32660. * Sets the reference Vector3 with the i-th facet position in the world system
  32661. * @param i defines the facet index
  32662. * @param ref defines the target vector
  32663. * @returns the current mesh
  32664. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32665. */
  32666. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32667. /**
  32668. * Returns the i-th facet normal in the world system.
  32669. * This method allocates a new Vector3 per call
  32670. * @param i defines the facet index
  32671. * @returns a new Vector3
  32672. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32673. */
  32674. getFacetNormal(i: number): Vector3;
  32675. /**
  32676. * Sets the reference Vector3 with the i-th facet normal in the world system
  32677. * @param i defines the facet index
  32678. * @param ref defines the target vector
  32679. * @returns the current mesh
  32680. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32681. */
  32682. getFacetNormalToRef(i: number, ref: Vector3): this;
  32683. /**
  32684. * 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)
  32685. * @param x defines x coordinate
  32686. * @param y defines y coordinate
  32687. * @param z defines z coordinate
  32688. * @returns the array of facet indexes
  32689. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32690. */
  32691. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32692. /**
  32693. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32694. * @param projected sets as the (x,y,z) world projection on the facet
  32695. * @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
  32696. * @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
  32697. * @param x defines x coordinate
  32698. * @param y defines y coordinate
  32699. * @param z defines z coordinate
  32700. * @returns the face index if found (or null instead)
  32701. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32702. */
  32703. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32704. /**
  32705. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32706. * @param projected sets as the (x,y,z) local projection on the facet
  32707. * @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
  32708. * @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
  32709. * @param x defines x coordinate
  32710. * @param y defines y coordinate
  32711. * @param z defines z coordinate
  32712. * @returns the face index if found (or null instead)
  32713. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32714. */
  32715. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32716. /**
  32717. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32718. * @returns the parameters
  32719. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32720. */
  32721. getFacetDataParameters(): any;
  32722. /**
  32723. * Disables the feature FacetData and frees the related memory
  32724. * @returns the current mesh
  32725. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32726. */
  32727. disableFacetData(): AbstractMesh;
  32728. /**
  32729. * Updates the AbstractMesh indices array
  32730. * @param indices defines the data source
  32731. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32732. * @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)
  32733. * @returns the current mesh
  32734. */
  32735. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32736. /**
  32737. * Creates new normals data for the mesh
  32738. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32739. * @returns the current mesh
  32740. */
  32741. createNormals(updatable: boolean): AbstractMesh;
  32742. /**
  32743. * Align the mesh with a normal
  32744. * @param normal defines the normal to use
  32745. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32746. * @returns the current mesh
  32747. */
  32748. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32749. /** @hidden */
  32750. _checkOcclusionQuery(): boolean;
  32751. /**
  32752. * Disables the mesh edge rendering mode
  32753. * @returns the currentAbstractMesh
  32754. */
  32755. disableEdgesRendering(): AbstractMesh;
  32756. /**
  32757. * Enables the edge rendering mode on the mesh.
  32758. * This mode makes the mesh edges visible
  32759. * @param epsilon defines the maximal distance between two angles to detect a face
  32760. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32761. * @returns the currentAbstractMesh
  32762. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32763. */
  32764. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32765. /**
  32766. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32767. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32768. */
  32769. getConnectedParticleSystems(): IParticleSystem[];
  32770. }
  32771. }
  32772. declare module BABYLON {
  32773. /**
  32774. * Interface used to define ActionEvent
  32775. */
  32776. export interface IActionEvent {
  32777. /** The mesh or sprite that triggered the action */
  32778. source: any;
  32779. /** The X mouse cursor position at the time of the event */
  32780. pointerX: number;
  32781. /** The Y mouse cursor position at the time of the event */
  32782. pointerY: number;
  32783. /** The mesh that is currently pointed at (can be null) */
  32784. meshUnderPointer: Nullable<AbstractMesh>;
  32785. /** the original (browser) event that triggered the ActionEvent */
  32786. sourceEvent?: any;
  32787. /** additional data for the event */
  32788. additionalData?: any;
  32789. }
  32790. /**
  32791. * ActionEvent is the event being sent when an action is triggered.
  32792. */
  32793. export class ActionEvent implements IActionEvent {
  32794. /** The mesh or sprite that triggered the action */
  32795. source: any;
  32796. /** The X mouse cursor position at the time of the event */
  32797. pointerX: number;
  32798. /** The Y mouse cursor position at the time of the event */
  32799. pointerY: number;
  32800. /** The mesh that is currently pointed at (can be null) */
  32801. meshUnderPointer: Nullable<AbstractMesh>;
  32802. /** the original (browser) event that triggered the ActionEvent */
  32803. sourceEvent?: any;
  32804. /** additional data for the event */
  32805. additionalData?: any;
  32806. /**
  32807. * Creates a new ActionEvent
  32808. * @param source The mesh or sprite that triggered the action
  32809. * @param pointerX The X mouse cursor position at the time of the event
  32810. * @param pointerY The Y mouse cursor position at the time of the event
  32811. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32812. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32813. * @param additionalData additional data for the event
  32814. */
  32815. constructor(
  32816. /** The mesh or sprite that triggered the action */
  32817. source: any,
  32818. /** The X mouse cursor position at the time of the event */
  32819. pointerX: number,
  32820. /** The Y mouse cursor position at the time of the event */
  32821. pointerY: number,
  32822. /** The mesh that is currently pointed at (can be null) */
  32823. meshUnderPointer: Nullable<AbstractMesh>,
  32824. /** the original (browser) event that triggered the ActionEvent */
  32825. sourceEvent?: any,
  32826. /** additional data for the event */
  32827. additionalData?: any);
  32828. /**
  32829. * Helper function to auto-create an ActionEvent from a source mesh.
  32830. * @param source The source mesh that triggered the event
  32831. * @param evt The original (browser) event
  32832. * @param additionalData additional data for the event
  32833. * @returns the new ActionEvent
  32834. */
  32835. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32836. /**
  32837. * Helper function to auto-create an ActionEvent from a source sprite
  32838. * @param source The source sprite that triggered the event
  32839. * @param scene Scene associated with the sprite
  32840. * @param evt The original (browser) event
  32841. * @param additionalData additional data for the event
  32842. * @returns the new ActionEvent
  32843. */
  32844. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32845. /**
  32846. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32847. * @param scene the scene where the event occurred
  32848. * @param evt The original (browser) event
  32849. * @returns the new ActionEvent
  32850. */
  32851. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32852. /**
  32853. * Helper function to auto-create an ActionEvent from a primitive
  32854. * @param prim defines the target primitive
  32855. * @param pointerPos defines the pointer position
  32856. * @param evt The original (browser) event
  32857. * @param additionalData additional data for the event
  32858. * @returns the new ActionEvent
  32859. */
  32860. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32861. }
  32862. }
  32863. declare module BABYLON {
  32864. /**
  32865. * Abstract class used to decouple action Manager from scene and meshes.
  32866. * Do not instantiate.
  32867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32868. */
  32869. export abstract class AbstractActionManager implements IDisposable {
  32870. /** Gets the list of active triggers */
  32871. static Triggers: {
  32872. [key: string]: number;
  32873. };
  32874. /** Gets the cursor to use when hovering items */
  32875. hoverCursor: string;
  32876. /** Gets the list of actions */
  32877. actions: IAction[];
  32878. /**
  32879. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32880. */
  32881. isRecursive: boolean;
  32882. /**
  32883. * Releases all associated resources
  32884. */
  32885. abstract dispose(): void;
  32886. /**
  32887. * Does this action manager has pointer triggers
  32888. */
  32889. abstract get hasPointerTriggers(): boolean;
  32890. /**
  32891. * Does this action manager has pick triggers
  32892. */
  32893. abstract get hasPickTriggers(): boolean;
  32894. /**
  32895. * Process a specific trigger
  32896. * @param trigger defines the trigger to process
  32897. * @param evt defines the event details to be processed
  32898. */
  32899. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32900. /**
  32901. * Does this action manager handles actions of any of the given triggers
  32902. * @param triggers defines the triggers to be tested
  32903. * @return a boolean indicating whether one (or more) of the triggers is handled
  32904. */
  32905. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32906. /**
  32907. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32908. * speed.
  32909. * @param triggerA defines the trigger to be tested
  32910. * @param triggerB defines the trigger to be tested
  32911. * @return a boolean indicating whether one (or more) of the triggers is handled
  32912. */
  32913. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32914. /**
  32915. * Does this action manager handles actions of a given trigger
  32916. * @param trigger defines the trigger to be tested
  32917. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32918. * @return whether the trigger is handled
  32919. */
  32920. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32921. /**
  32922. * Serialize this manager to a JSON object
  32923. * @param name defines the property name to store this manager
  32924. * @returns a JSON representation of this manager
  32925. */
  32926. abstract serialize(name: string): any;
  32927. /**
  32928. * Registers an action to this action manager
  32929. * @param action defines the action to be registered
  32930. * @return the action amended (prepared) after registration
  32931. */
  32932. abstract registerAction(action: IAction): Nullable<IAction>;
  32933. /**
  32934. * Unregisters an action to this action manager
  32935. * @param action defines the action to be unregistered
  32936. * @return a boolean indicating whether the action has been unregistered
  32937. */
  32938. abstract unregisterAction(action: IAction): Boolean;
  32939. /**
  32940. * Does exist one action manager with at least one trigger
  32941. **/
  32942. static get HasTriggers(): boolean;
  32943. /**
  32944. * Does exist one action manager with at least one pick trigger
  32945. **/
  32946. static get HasPickTriggers(): boolean;
  32947. /**
  32948. * Does exist one action manager that handles actions of a given trigger
  32949. * @param trigger defines the trigger to be tested
  32950. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32951. **/
  32952. static HasSpecificTrigger(trigger: number): boolean;
  32953. }
  32954. }
  32955. declare module BABYLON {
  32956. /**
  32957. * Defines how a node can be built from a string name.
  32958. */
  32959. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32960. /**
  32961. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32962. */
  32963. export class Node implements IBehaviorAware<Node> {
  32964. /** @hidden */
  32965. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32966. private static _NodeConstructors;
  32967. /**
  32968. * Add a new node constructor
  32969. * @param type defines the type name of the node to construct
  32970. * @param constructorFunc defines the constructor function
  32971. */
  32972. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32973. /**
  32974. * Returns a node constructor based on type name
  32975. * @param type defines the type name
  32976. * @param name defines the new node name
  32977. * @param scene defines the hosting scene
  32978. * @param options defines optional options to transmit to constructors
  32979. * @returns the new constructor or null
  32980. */
  32981. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32982. /**
  32983. * Gets or sets the name of the node
  32984. */
  32985. name: string;
  32986. /**
  32987. * Gets or sets the id of the node
  32988. */
  32989. id: string;
  32990. /**
  32991. * Gets or sets the unique id of the node
  32992. */
  32993. uniqueId: number;
  32994. /**
  32995. * Gets or sets a string used to store user defined state for the node
  32996. */
  32997. state: string;
  32998. /**
  32999. * Gets or sets an object used to store user defined information for the node
  33000. */
  33001. metadata: any;
  33002. /**
  33003. * For internal use only. Please do not use.
  33004. */
  33005. reservedDataStore: any;
  33006. /**
  33007. * List of inspectable custom properties (used by the Inspector)
  33008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33009. */
  33010. inspectableCustomProperties: IInspectable[];
  33011. private _doNotSerialize;
  33012. /**
  33013. * Gets or sets a boolean used to define if the node must be serialized
  33014. */
  33015. get doNotSerialize(): boolean;
  33016. set doNotSerialize(value: boolean);
  33017. /** @hidden */
  33018. _isDisposed: boolean;
  33019. /**
  33020. * Gets a list of Animations associated with the node
  33021. */
  33022. animations: Animation[];
  33023. protected _ranges: {
  33024. [name: string]: Nullable<AnimationRange>;
  33025. };
  33026. /**
  33027. * Callback raised when the node is ready to be used
  33028. */
  33029. onReady: Nullable<(node: Node) => void>;
  33030. private _isEnabled;
  33031. private _isParentEnabled;
  33032. private _isReady;
  33033. /** @hidden */
  33034. _currentRenderId: number;
  33035. private _parentUpdateId;
  33036. /** @hidden */
  33037. _childUpdateId: number;
  33038. /** @hidden */
  33039. _waitingParentId: Nullable<string>;
  33040. /** @hidden */
  33041. _scene: Scene;
  33042. /** @hidden */
  33043. _cache: any;
  33044. private _parentNode;
  33045. private _children;
  33046. /** @hidden */
  33047. _worldMatrix: Matrix;
  33048. /** @hidden */
  33049. _worldMatrixDeterminant: number;
  33050. /** @hidden */
  33051. _worldMatrixDeterminantIsDirty: boolean;
  33052. /** @hidden */
  33053. private _sceneRootNodesIndex;
  33054. /**
  33055. * Gets a boolean indicating if the node has been disposed
  33056. * @returns true if the node was disposed
  33057. */
  33058. isDisposed(): boolean;
  33059. /**
  33060. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33061. * @see https://doc.babylonjs.com/how_to/parenting
  33062. */
  33063. set parent(parent: Nullable<Node>);
  33064. get parent(): Nullable<Node>;
  33065. /** @hidden */
  33066. _addToSceneRootNodes(): void;
  33067. /** @hidden */
  33068. _removeFromSceneRootNodes(): void;
  33069. private _animationPropertiesOverride;
  33070. /**
  33071. * Gets or sets the animation properties override
  33072. */
  33073. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33074. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33075. /**
  33076. * Gets a string identifying the name of the class
  33077. * @returns "Node" string
  33078. */
  33079. getClassName(): string;
  33080. /** @hidden */
  33081. readonly _isNode: boolean;
  33082. /**
  33083. * An event triggered when the mesh is disposed
  33084. */
  33085. onDisposeObservable: Observable<Node>;
  33086. private _onDisposeObserver;
  33087. /**
  33088. * Sets a callback that will be raised when the node will be disposed
  33089. */
  33090. set onDispose(callback: () => void);
  33091. /**
  33092. * Creates a new Node
  33093. * @param name the name and id to be given to this node
  33094. * @param scene the scene this node will be added to
  33095. */
  33096. constructor(name: string, scene?: Nullable<Scene>);
  33097. /**
  33098. * Gets the scene of the node
  33099. * @returns a scene
  33100. */
  33101. getScene(): Scene;
  33102. /**
  33103. * Gets the engine of the node
  33104. * @returns a Engine
  33105. */
  33106. getEngine(): Engine;
  33107. private _behaviors;
  33108. /**
  33109. * Attach a behavior to the node
  33110. * @see https://doc.babylonjs.com/features/behaviour
  33111. * @param behavior defines the behavior to attach
  33112. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33113. * @returns the current Node
  33114. */
  33115. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33116. /**
  33117. * Remove an attached behavior
  33118. * @see https://doc.babylonjs.com/features/behaviour
  33119. * @param behavior defines the behavior to attach
  33120. * @returns the current Node
  33121. */
  33122. removeBehavior(behavior: Behavior<Node>): Node;
  33123. /**
  33124. * Gets the list of attached behaviors
  33125. * @see https://doc.babylonjs.com/features/behaviour
  33126. */
  33127. get behaviors(): Behavior<Node>[];
  33128. /**
  33129. * Gets an attached behavior by name
  33130. * @param name defines the name of the behavior to look for
  33131. * @see https://doc.babylonjs.com/features/behaviour
  33132. * @returns null if behavior was not found else the requested behavior
  33133. */
  33134. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33135. /**
  33136. * Returns the latest update of the World matrix
  33137. * @returns a Matrix
  33138. */
  33139. getWorldMatrix(): Matrix;
  33140. /** @hidden */
  33141. _getWorldMatrixDeterminant(): number;
  33142. /**
  33143. * Returns directly the latest state of the mesh World matrix.
  33144. * A Matrix is returned.
  33145. */
  33146. get worldMatrixFromCache(): Matrix;
  33147. /** @hidden */
  33148. _initCache(): void;
  33149. /** @hidden */
  33150. updateCache(force?: boolean): void;
  33151. /** @hidden */
  33152. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33153. /** @hidden */
  33154. _updateCache(ignoreParentClass?: boolean): void;
  33155. /** @hidden */
  33156. _isSynchronized(): boolean;
  33157. /** @hidden */
  33158. _markSyncedWithParent(): void;
  33159. /** @hidden */
  33160. isSynchronizedWithParent(): boolean;
  33161. /** @hidden */
  33162. isSynchronized(): boolean;
  33163. /**
  33164. * Is this node ready to be used/rendered
  33165. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33166. * @return true if the node is ready
  33167. */
  33168. isReady(completeCheck?: boolean): boolean;
  33169. /**
  33170. * Is this node enabled?
  33171. * 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
  33172. * @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
  33173. * @return whether this node (and its parent) is enabled
  33174. */
  33175. isEnabled(checkAncestors?: boolean): boolean;
  33176. /** @hidden */
  33177. protected _syncParentEnabledState(): void;
  33178. /**
  33179. * Set the enabled state of this node
  33180. * @param value defines the new enabled state
  33181. */
  33182. setEnabled(value: boolean): void;
  33183. /**
  33184. * Is this node a descendant of the given node?
  33185. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33186. * @param ancestor defines the parent node to inspect
  33187. * @returns a boolean indicating if this node is a descendant of the given node
  33188. */
  33189. isDescendantOf(ancestor: Node): boolean;
  33190. /** @hidden */
  33191. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33192. /**
  33193. * Will return all nodes that have this node as ascendant
  33194. * @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
  33195. * @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
  33196. * @return all children nodes of all types
  33197. */
  33198. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33199. /**
  33200. * Get all child-meshes of this node
  33201. * @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)
  33202. * @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
  33203. * @returns an array of AbstractMesh
  33204. */
  33205. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33206. /**
  33207. * Get all direct children of this node
  33208. * @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
  33209. * @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)
  33210. * @returns an array of Node
  33211. */
  33212. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33213. /** @hidden */
  33214. _setReady(state: boolean): void;
  33215. /**
  33216. * Get an animation by name
  33217. * @param name defines the name of the animation to look for
  33218. * @returns null if not found else the requested animation
  33219. */
  33220. getAnimationByName(name: string): Nullable<Animation>;
  33221. /**
  33222. * Creates an animation range for this node
  33223. * @param name defines the name of the range
  33224. * @param from defines the starting key
  33225. * @param to defines the end key
  33226. */
  33227. createAnimationRange(name: string, from: number, to: number): void;
  33228. /**
  33229. * Delete a specific animation range
  33230. * @param name defines the name of the range to delete
  33231. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33232. */
  33233. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33234. /**
  33235. * Get an animation range by name
  33236. * @param name defines the name of the animation range to look for
  33237. * @returns null if not found else the requested animation range
  33238. */
  33239. getAnimationRange(name: string): Nullable<AnimationRange>;
  33240. /**
  33241. * Gets the list of all animation ranges defined on this node
  33242. * @returns an array
  33243. */
  33244. getAnimationRanges(): Nullable<AnimationRange>[];
  33245. /**
  33246. * Will start the animation sequence
  33247. * @param name defines the range frames for animation sequence
  33248. * @param loop defines if the animation should loop (false by default)
  33249. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33250. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33251. * @returns the object created for this animation. If range does not exist, it will return null
  33252. */
  33253. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33254. /**
  33255. * Serialize animation ranges into a JSON compatible object
  33256. * @returns serialization object
  33257. */
  33258. serializeAnimationRanges(): any;
  33259. /**
  33260. * Computes the world matrix of the node
  33261. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33262. * @returns the world matrix
  33263. */
  33264. computeWorldMatrix(force?: boolean): Matrix;
  33265. /**
  33266. * Releases resources associated with this node.
  33267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33269. */
  33270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33271. /**
  33272. * Parse animation range data from a serialization object and store them into a given node
  33273. * @param node defines where to store the animation ranges
  33274. * @param parsedNode defines the serialization object to read data from
  33275. * @param scene defines the hosting scene
  33276. */
  33277. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33278. /**
  33279. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33280. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33281. * @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
  33282. * @returns the new bounding vectors
  33283. */
  33284. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33285. min: Vector3;
  33286. max: Vector3;
  33287. };
  33288. }
  33289. }
  33290. declare module BABYLON {
  33291. /**
  33292. * @hidden
  33293. */
  33294. export class _IAnimationState {
  33295. key: number;
  33296. repeatCount: number;
  33297. workValue?: any;
  33298. loopMode?: number;
  33299. offsetValue?: any;
  33300. highLimitValue?: any;
  33301. }
  33302. /**
  33303. * Class used to store any kind of animation
  33304. */
  33305. export class Animation {
  33306. /**Name of the animation */
  33307. name: string;
  33308. /**Property to animate */
  33309. targetProperty: string;
  33310. /**The frames per second of the animation */
  33311. framePerSecond: number;
  33312. /**The data type of the animation */
  33313. dataType: number;
  33314. /**The loop mode of the animation */
  33315. loopMode?: number | undefined;
  33316. /**Specifies if blending should be enabled */
  33317. enableBlending?: boolean | undefined;
  33318. /**
  33319. * Use matrix interpolation instead of using direct key value when animating matrices
  33320. */
  33321. static AllowMatricesInterpolation: boolean;
  33322. /**
  33323. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33324. */
  33325. static AllowMatrixDecomposeForInterpolation: boolean;
  33326. /** Define the Url to load snippets */
  33327. static SnippetUrl: string;
  33328. /** Snippet ID if the animation was created from the snippet server */
  33329. snippetId: string;
  33330. /**
  33331. * Stores the key frames of the animation
  33332. */
  33333. private _keys;
  33334. /**
  33335. * Stores the easing function of the animation
  33336. */
  33337. private _easingFunction;
  33338. /**
  33339. * @hidden Internal use only
  33340. */
  33341. _runtimeAnimations: RuntimeAnimation[];
  33342. /**
  33343. * The set of event that will be linked to this animation
  33344. */
  33345. private _events;
  33346. /**
  33347. * Stores an array of target property paths
  33348. */
  33349. targetPropertyPath: string[];
  33350. /**
  33351. * Stores the blending speed of the animation
  33352. */
  33353. blendingSpeed: number;
  33354. /**
  33355. * Stores the animation ranges for the animation
  33356. */
  33357. private _ranges;
  33358. /**
  33359. * @hidden Internal use
  33360. */
  33361. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33362. /**
  33363. * Sets up an animation
  33364. * @param property The property to animate
  33365. * @param animationType The animation type to apply
  33366. * @param framePerSecond The frames per second of the animation
  33367. * @param easingFunction The easing function used in the animation
  33368. * @returns The created animation
  33369. */
  33370. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33371. /**
  33372. * Create and start an animation on a node
  33373. * @param name defines the name of the global animation that will be run on all nodes
  33374. * @param node defines the root node where the animation will take place
  33375. * @param targetProperty defines property to animate
  33376. * @param framePerSecond defines the number of frame per second yo use
  33377. * @param totalFrame defines the number of frames in total
  33378. * @param from defines the initial value
  33379. * @param to defines the final value
  33380. * @param loopMode defines which loop mode you want to use (off by default)
  33381. * @param easingFunction defines the easing function to use (linear by default)
  33382. * @param onAnimationEnd defines the callback to call when animation end
  33383. * @returns the animatable created for this animation
  33384. */
  33385. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33386. /**
  33387. * Create and start an animation on a node and its descendants
  33388. * @param name defines the name of the global animation that will be run on all nodes
  33389. * @param node defines the root node where the animation will take place
  33390. * @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
  33391. * @param targetProperty defines property to animate
  33392. * @param framePerSecond defines the number of frame per second to use
  33393. * @param totalFrame defines the number of frames in total
  33394. * @param from defines the initial value
  33395. * @param to defines the final value
  33396. * @param loopMode defines which loop mode you want to use (off by default)
  33397. * @param easingFunction defines the easing function to use (linear by default)
  33398. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33399. * @returns the list of animatables created for all nodes
  33400. * @example https://www.babylonjs-playground.com/#MH0VLI
  33401. */
  33402. 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[]>;
  33403. /**
  33404. * Creates a new animation, merges it with the existing animations and starts it
  33405. * @param name Name of the animation
  33406. * @param node Node which contains the scene that begins the animations
  33407. * @param targetProperty Specifies which property to animate
  33408. * @param framePerSecond The frames per second of the animation
  33409. * @param totalFrame The total number of frames
  33410. * @param from The frame at the beginning of the animation
  33411. * @param to The frame at the end of the animation
  33412. * @param loopMode Specifies the loop mode of the animation
  33413. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33414. * @param onAnimationEnd Callback to run once the animation is complete
  33415. * @returns Nullable animation
  33416. */
  33417. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33418. /**
  33419. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33420. * @param sourceAnimation defines the Animation containing keyframes to convert
  33421. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33422. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33423. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33424. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33425. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33426. */
  33427. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33428. /**
  33429. * Transition property of an host to the target Value
  33430. * @param property The property to transition
  33431. * @param targetValue The target Value of the property
  33432. * @param host The object where the property to animate belongs
  33433. * @param scene Scene used to run the animation
  33434. * @param frameRate Framerate (in frame/s) to use
  33435. * @param transition The transition type we want to use
  33436. * @param duration The duration of the animation, in milliseconds
  33437. * @param onAnimationEnd Callback trigger at the end of the animation
  33438. * @returns Nullable animation
  33439. */
  33440. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33441. /**
  33442. * Return the array of runtime animations currently using this animation
  33443. */
  33444. get runtimeAnimations(): RuntimeAnimation[];
  33445. /**
  33446. * Specifies if any of the runtime animations are currently running
  33447. */
  33448. get hasRunningRuntimeAnimations(): boolean;
  33449. /**
  33450. * Initializes the animation
  33451. * @param name Name of the animation
  33452. * @param targetProperty Property to animate
  33453. * @param framePerSecond The frames per second of the animation
  33454. * @param dataType The data type of the animation
  33455. * @param loopMode The loop mode of the animation
  33456. * @param enableBlending Specifies if blending should be enabled
  33457. */
  33458. constructor(
  33459. /**Name of the animation */
  33460. name: string,
  33461. /**Property to animate */
  33462. targetProperty: string,
  33463. /**The frames per second of the animation */
  33464. framePerSecond: number,
  33465. /**The data type of the animation */
  33466. dataType: number,
  33467. /**The loop mode of the animation */
  33468. loopMode?: number | undefined,
  33469. /**Specifies if blending should be enabled */
  33470. enableBlending?: boolean | undefined);
  33471. /**
  33472. * Converts the animation to a string
  33473. * @param fullDetails support for multiple levels of logging within scene loading
  33474. * @returns String form of the animation
  33475. */
  33476. toString(fullDetails?: boolean): string;
  33477. /**
  33478. * Add an event to this animation
  33479. * @param event Event to add
  33480. */
  33481. addEvent(event: AnimationEvent): void;
  33482. /**
  33483. * Remove all events found at the given frame
  33484. * @param frame The frame to remove events from
  33485. */
  33486. removeEvents(frame: number): void;
  33487. /**
  33488. * Retrieves all the events from the animation
  33489. * @returns Events from the animation
  33490. */
  33491. getEvents(): AnimationEvent[];
  33492. /**
  33493. * Creates an animation range
  33494. * @param name Name of the animation range
  33495. * @param from Starting frame of the animation range
  33496. * @param to Ending frame of the animation
  33497. */
  33498. createRange(name: string, from: number, to: number): void;
  33499. /**
  33500. * Deletes an animation range by name
  33501. * @param name Name of the animation range to delete
  33502. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33503. */
  33504. deleteRange(name: string, deleteFrames?: boolean): void;
  33505. /**
  33506. * Gets the animation range by name, or null if not defined
  33507. * @param name Name of the animation range
  33508. * @returns Nullable animation range
  33509. */
  33510. getRange(name: string): Nullable<AnimationRange>;
  33511. /**
  33512. * Gets the key frames from the animation
  33513. * @returns The key frames of the animation
  33514. */
  33515. getKeys(): Array<IAnimationKey>;
  33516. /**
  33517. * Gets the highest frame rate of the animation
  33518. * @returns Highest frame rate of the animation
  33519. */
  33520. getHighestFrame(): number;
  33521. /**
  33522. * Gets the easing function of the animation
  33523. * @returns Easing function of the animation
  33524. */
  33525. getEasingFunction(): IEasingFunction;
  33526. /**
  33527. * Sets the easing function of the animation
  33528. * @param easingFunction A custom mathematical formula for animation
  33529. */
  33530. setEasingFunction(easingFunction: EasingFunction): void;
  33531. /**
  33532. * Interpolates a scalar linearly
  33533. * @param startValue Start value of the animation curve
  33534. * @param endValue End value of the animation curve
  33535. * @param gradient Scalar amount to interpolate
  33536. * @returns Interpolated scalar value
  33537. */
  33538. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33539. /**
  33540. * Interpolates a scalar cubically
  33541. * @param startValue Start value of the animation curve
  33542. * @param outTangent End tangent of the animation
  33543. * @param endValue End value of the animation curve
  33544. * @param inTangent Start tangent of the animation curve
  33545. * @param gradient Scalar amount to interpolate
  33546. * @returns Interpolated scalar value
  33547. */
  33548. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33549. /**
  33550. * Interpolates a quaternion using a spherical linear interpolation
  33551. * @param startValue Start value of the animation curve
  33552. * @param endValue End value of the animation curve
  33553. * @param gradient Scalar amount to interpolate
  33554. * @returns Interpolated quaternion value
  33555. */
  33556. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33557. /**
  33558. * Interpolates a quaternion cubically
  33559. * @param startValue Start value of the animation curve
  33560. * @param outTangent End tangent of the animation curve
  33561. * @param endValue End value of the animation curve
  33562. * @param inTangent Start tangent of the animation curve
  33563. * @param gradient Scalar amount to interpolate
  33564. * @returns Interpolated quaternion value
  33565. */
  33566. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33567. /**
  33568. * Interpolates a Vector3 linearl
  33569. * @param startValue Start value of the animation curve
  33570. * @param endValue End value of the animation curve
  33571. * @param gradient Scalar amount to interpolate
  33572. * @returns Interpolated scalar value
  33573. */
  33574. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33575. /**
  33576. * Interpolates a Vector3 cubically
  33577. * @param startValue Start value of the animation curve
  33578. * @param outTangent End tangent of the animation
  33579. * @param endValue End value of the animation curve
  33580. * @param inTangent Start tangent of the animation curve
  33581. * @param gradient Scalar amount to interpolate
  33582. * @returns InterpolatedVector3 value
  33583. */
  33584. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33585. /**
  33586. * Interpolates a Vector2 linearly
  33587. * @param startValue Start value of the animation curve
  33588. * @param endValue End value of the animation curve
  33589. * @param gradient Scalar amount to interpolate
  33590. * @returns Interpolated Vector2 value
  33591. */
  33592. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33593. /**
  33594. * Interpolates a Vector2 cubically
  33595. * @param startValue Start value of the animation curve
  33596. * @param outTangent End tangent of the animation
  33597. * @param endValue End value of the animation curve
  33598. * @param inTangent Start tangent of the animation curve
  33599. * @param gradient Scalar amount to interpolate
  33600. * @returns Interpolated Vector2 value
  33601. */
  33602. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33603. /**
  33604. * Interpolates a size linearly
  33605. * @param startValue Start value of the animation curve
  33606. * @param endValue End value of the animation curve
  33607. * @param gradient Scalar amount to interpolate
  33608. * @returns Interpolated Size value
  33609. */
  33610. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33611. /**
  33612. * Interpolates a Color3 linearly
  33613. * @param startValue Start value of the animation curve
  33614. * @param endValue End value of the animation curve
  33615. * @param gradient Scalar amount to interpolate
  33616. * @returns Interpolated Color3 value
  33617. */
  33618. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33619. /**
  33620. * Interpolates a Color4 linearly
  33621. * @param startValue Start value of the animation curve
  33622. * @param endValue End value of the animation curve
  33623. * @param gradient Scalar amount to interpolate
  33624. * @returns Interpolated Color3 value
  33625. */
  33626. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33627. /**
  33628. * @hidden Internal use only
  33629. */
  33630. _getKeyValue(value: any): any;
  33631. /**
  33632. * @hidden Internal use only
  33633. */
  33634. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33635. /**
  33636. * Defines the function to use to interpolate matrices
  33637. * @param startValue defines the start matrix
  33638. * @param endValue defines the end matrix
  33639. * @param gradient defines the gradient between both matrices
  33640. * @param result defines an optional target matrix where to store the interpolation
  33641. * @returns the interpolated matrix
  33642. */
  33643. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33644. /**
  33645. * Makes a copy of the animation
  33646. * @returns Cloned animation
  33647. */
  33648. clone(): Animation;
  33649. /**
  33650. * Sets the key frames of the animation
  33651. * @param values The animation key frames to set
  33652. */
  33653. setKeys(values: Array<IAnimationKey>): void;
  33654. /**
  33655. * Serializes the animation to an object
  33656. * @returns Serialized object
  33657. */
  33658. serialize(): any;
  33659. /**
  33660. * Float animation type
  33661. */
  33662. static readonly ANIMATIONTYPE_FLOAT: number;
  33663. /**
  33664. * Vector3 animation type
  33665. */
  33666. static readonly ANIMATIONTYPE_VECTOR3: number;
  33667. /**
  33668. * Quaternion animation type
  33669. */
  33670. static readonly ANIMATIONTYPE_QUATERNION: number;
  33671. /**
  33672. * Matrix animation type
  33673. */
  33674. static readonly ANIMATIONTYPE_MATRIX: number;
  33675. /**
  33676. * Color3 animation type
  33677. */
  33678. static readonly ANIMATIONTYPE_COLOR3: number;
  33679. /**
  33680. * Color3 animation type
  33681. */
  33682. static readonly ANIMATIONTYPE_COLOR4: number;
  33683. /**
  33684. * Vector2 animation type
  33685. */
  33686. static readonly ANIMATIONTYPE_VECTOR2: number;
  33687. /**
  33688. * Size animation type
  33689. */
  33690. static readonly ANIMATIONTYPE_SIZE: number;
  33691. /**
  33692. * Relative Loop Mode
  33693. */
  33694. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33695. /**
  33696. * Cycle Loop Mode
  33697. */
  33698. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33699. /**
  33700. * Constant Loop Mode
  33701. */
  33702. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33703. /** @hidden */
  33704. static _UniversalLerp(left: any, right: any, amount: number): any;
  33705. /**
  33706. * Parses an animation object and creates an animation
  33707. * @param parsedAnimation Parsed animation object
  33708. * @returns Animation object
  33709. */
  33710. static Parse(parsedAnimation: any): Animation;
  33711. /**
  33712. * Appends the serialized animations from the source animations
  33713. * @param source Source containing the animations
  33714. * @param destination Target to store the animations
  33715. */
  33716. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33717. /**
  33718. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33719. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33720. * @param url defines the url to load from
  33721. * @returns a promise that will resolve to the new animation or an array of animations
  33722. */
  33723. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33724. /**
  33725. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33726. * @param snippetId defines the snippet to load
  33727. * @returns a promise that will resolve to the new animation or a new array of animations
  33728. */
  33729. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33730. }
  33731. }
  33732. declare module BABYLON {
  33733. /**
  33734. * Interface containing an array of animations
  33735. */
  33736. export interface IAnimatable {
  33737. /**
  33738. * Array of animations
  33739. */
  33740. animations: Nullable<Array<Animation>>;
  33741. }
  33742. }
  33743. declare module BABYLON {
  33744. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33745. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33746. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33747. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33748. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33749. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33750. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33751. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33752. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33753. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33754. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33755. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33756. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33757. /**
  33758. * Decorator used to define property that can be serialized as reference to a camera
  33759. * @param sourceName defines the name of the property to decorate
  33760. */
  33761. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33762. /**
  33763. * Class used to help serialization objects
  33764. */
  33765. export class SerializationHelper {
  33766. /** @hidden */
  33767. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33768. /** @hidden */
  33769. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33770. /** @hidden */
  33771. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33772. /** @hidden */
  33773. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33774. /**
  33775. * Appends the serialized animations from the source animations
  33776. * @param source Source containing the animations
  33777. * @param destination Target to store the animations
  33778. */
  33779. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33780. /**
  33781. * Static function used to serialized a specific entity
  33782. * @param entity defines the entity to serialize
  33783. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33784. * @returns a JSON compatible object representing the serialization of the entity
  33785. */
  33786. static Serialize<T>(entity: T, serializationObject?: any): any;
  33787. /**
  33788. * Creates a new entity from a serialization data object
  33789. * @param creationFunction defines a function used to instanciated the new entity
  33790. * @param source defines the source serialization data
  33791. * @param scene defines the hosting scene
  33792. * @param rootUrl defines the root url for resources
  33793. * @returns a new entity
  33794. */
  33795. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33796. /**
  33797. * Clones an object
  33798. * @param creationFunction defines the function used to instanciate the new object
  33799. * @param source defines the source object
  33800. * @returns the cloned object
  33801. */
  33802. static Clone<T>(creationFunction: () => T, source: T): T;
  33803. /**
  33804. * Instanciates a new object based on a source one (some data will be shared between both object)
  33805. * @param creationFunction defines the function used to instanciate the new object
  33806. * @param source defines the source object
  33807. * @returns the new object
  33808. */
  33809. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33810. }
  33811. }
  33812. declare module BABYLON {
  33813. /**
  33814. * Base class of all the textures in babylon.
  33815. * It groups all the common properties the materials, post process, lights... might need
  33816. * in order to make a correct use of the texture.
  33817. */
  33818. export class BaseTexture implements IAnimatable {
  33819. /**
  33820. * Default anisotropic filtering level for the application.
  33821. * It is set to 4 as a good tradeoff between perf and quality.
  33822. */
  33823. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33824. /**
  33825. * Gets or sets the unique id of the texture
  33826. */
  33827. uniqueId: number;
  33828. /**
  33829. * Define the name of the texture.
  33830. */
  33831. name: string;
  33832. /**
  33833. * Gets or sets an object used to store user defined information.
  33834. */
  33835. metadata: any;
  33836. /**
  33837. * For internal use only. Please do not use.
  33838. */
  33839. reservedDataStore: any;
  33840. private _hasAlpha;
  33841. /**
  33842. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33843. */
  33844. set hasAlpha(value: boolean);
  33845. get hasAlpha(): boolean;
  33846. /**
  33847. * Defines if the alpha value should be determined via the rgb values.
  33848. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33849. */
  33850. getAlphaFromRGB: boolean;
  33851. /**
  33852. * Intensity or strength of the texture.
  33853. * It is commonly used by materials to fine tune the intensity of the texture
  33854. */
  33855. level: number;
  33856. /**
  33857. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33858. * This is part of the texture as textures usually maps to one uv set.
  33859. */
  33860. coordinatesIndex: number;
  33861. private _coordinatesMode;
  33862. /**
  33863. * How a texture is mapped.
  33864. *
  33865. * | Value | Type | Description |
  33866. * | ----- | ----------------------------------- | ----------- |
  33867. * | 0 | EXPLICIT_MODE | |
  33868. * | 1 | SPHERICAL_MODE | |
  33869. * | 2 | PLANAR_MODE | |
  33870. * | 3 | CUBIC_MODE | |
  33871. * | 4 | PROJECTION_MODE | |
  33872. * | 5 | SKYBOX_MODE | |
  33873. * | 6 | INVCUBIC_MODE | |
  33874. * | 7 | EQUIRECTANGULAR_MODE | |
  33875. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33876. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33877. */
  33878. set coordinatesMode(value: number);
  33879. get coordinatesMode(): number;
  33880. /**
  33881. * | Value | Type | Description |
  33882. * | ----- | ------------------ | ----------- |
  33883. * | 0 | CLAMP_ADDRESSMODE | |
  33884. * | 1 | WRAP_ADDRESSMODE | |
  33885. * | 2 | MIRROR_ADDRESSMODE | |
  33886. */
  33887. wrapU: number;
  33888. /**
  33889. * | Value | Type | Description |
  33890. * | ----- | ------------------ | ----------- |
  33891. * | 0 | CLAMP_ADDRESSMODE | |
  33892. * | 1 | WRAP_ADDRESSMODE | |
  33893. * | 2 | MIRROR_ADDRESSMODE | |
  33894. */
  33895. wrapV: number;
  33896. /**
  33897. * | Value | Type | Description |
  33898. * | ----- | ------------------ | ----------- |
  33899. * | 0 | CLAMP_ADDRESSMODE | |
  33900. * | 1 | WRAP_ADDRESSMODE | |
  33901. * | 2 | MIRROR_ADDRESSMODE | |
  33902. */
  33903. wrapR: number;
  33904. /**
  33905. * With compliant hardware and browser (supporting anisotropic filtering)
  33906. * this defines the level of anisotropic filtering in the texture.
  33907. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33908. */
  33909. anisotropicFilteringLevel: number;
  33910. /**
  33911. * Define if the texture is a cube texture or if false a 2d texture.
  33912. */
  33913. get isCube(): boolean;
  33914. set isCube(value: boolean);
  33915. /**
  33916. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33917. */
  33918. get is3D(): boolean;
  33919. set is3D(value: boolean);
  33920. /**
  33921. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33922. */
  33923. get is2DArray(): boolean;
  33924. set is2DArray(value: boolean);
  33925. /**
  33926. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33927. * HDR texture are usually stored in linear space.
  33928. * This only impacts the PBR and Background materials
  33929. */
  33930. gammaSpace: boolean;
  33931. /**
  33932. * Gets or sets whether or not the texture contains RGBD data.
  33933. */
  33934. get isRGBD(): boolean;
  33935. set isRGBD(value: boolean);
  33936. /**
  33937. * Is Z inverted in the texture (useful in a cube texture).
  33938. */
  33939. invertZ: boolean;
  33940. /**
  33941. * Are mip maps generated for this texture or not.
  33942. */
  33943. get noMipmap(): boolean;
  33944. /**
  33945. * @hidden
  33946. */
  33947. lodLevelInAlpha: boolean;
  33948. /**
  33949. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33950. */
  33951. get lodGenerationOffset(): number;
  33952. set lodGenerationOffset(value: number);
  33953. /**
  33954. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33955. */
  33956. get lodGenerationScale(): number;
  33957. set lodGenerationScale(value: number);
  33958. /**
  33959. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33960. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33961. * average roughness values.
  33962. */
  33963. get linearSpecularLOD(): boolean;
  33964. set linearSpecularLOD(value: boolean);
  33965. /**
  33966. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33967. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33968. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33969. */
  33970. get irradianceTexture(): Nullable<BaseTexture>;
  33971. set irradianceTexture(value: Nullable<BaseTexture>);
  33972. /**
  33973. * Define if the texture is a render target.
  33974. */
  33975. isRenderTarget: boolean;
  33976. /**
  33977. * Define the unique id of the texture in the scene.
  33978. */
  33979. get uid(): string;
  33980. /** @hidden */
  33981. _prefiltered: boolean;
  33982. /**
  33983. * Return a string representation of the texture.
  33984. * @returns the texture as a string
  33985. */
  33986. toString(): string;
  33987. /**
  33988. * Get the class name of the texture.
  33989. * @returns "BaseTexture"
  33990. */
  33991. getClassName(): string;
  33992. /**
  33993. * Define the list of animation attached to the texture.
  33994. */
  33995. animations: Animation[];
  33996. /**
  33997. * An event triggered when the texture is disposed.
  33998. */
  33999. onDisposeObservable: Observable<BaseTexture>;
  34000. private _onDisposeObserver;
  34001. /**
  34002. * Callback triggered when the texture has been disposed.
  34003. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34004. */
  34005. set onDispose(callback: () => void);
  34006. /**
  34007. * Define the current state of the loading sequence when in delayed load mode.
  34008. */
  34009. delayLoadState: number;
  34010. protected _scene: Nullable<Scene>;
  34011. protected _engine: Nullable<ThinEngine>;
  34012. /** @hidden */
  34013. _texture: Nullable<InternalTexture>;
  34014. private _uid;
  34015. /**
  34016. * Define if the texture is preventinga material to render or not.
  34017. * If not and the texture is not ready, the engine will use a default black texture instead.
  34018. */
  34019. get isBlocking(): boolean;
  34020. /**
  34021. * Instantiates a new BaseTexture.
  34022. * Base class of all the textures in babylon.
  34023. * It groups all the common properties the materials, post process, lights... might need
  34024. * in order to make a correct use of the texture.
  34025. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34026. */
  34027. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34028. /**
  34029. * Get the scene the texture belongs to.
  34030. * @returns the scene or null if undefined
  34031. */
  34032. getScene(): Nullable<Scene>;
  34033. /** @hidden */
  34034. protected _getEngine(): Nullable<ThinEngine>;
  34035. /**
  34036. * Get the texture transform matrix used to offset tile the texture for istance.
  34037. * @returns the transformation matrix
  34038. */
  34039. getTextureMatrix(): Matrix;
  34040. /**
  34041. * Get the texture reflection matrix used to rotate/transform the reflection.
  34042. * @returns the reflection matrix
  34043. */
  34044. getReflectionTextureMatrix(): Matrix;
  34045. /**
  34046. * Get the underlying lower level texture from Babylon.
  34047. * @returns the insternal texture
  34048. */
  34049. getInternalTexture(): Nullable<InternalTexture>;
  34050. /**
  34051. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34052. * @returns true if ready or not blocking
  34053. */
  34054. isReadyOrNotBlocking(): boolean;
  34055. /**
  34056. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34057. * @returns true if fully ready
  34058. */
  34059. isReady(): boolean;
  34060. private _cachedSize;
  34061. /**
  34062. * Get the size of the texture.
  34063. * @returns the texture size.
  34064. */
  34065. getSize(): ISize;
  34066. /**
  34067. * Get the base size of the texture.
  34068. * It can be different from the size if the texture has been resized for POT for instance
  34069. * @returns the base size
  34070. */
  34071. getBaseSize(): ISize;
  34072. /**
  34073. * Update the sampling mode of the texture.
  34074. * Default is Trilinear mode.
  34075. *
  34076. * | Value | Type | Description |
  34077. * | ----- | ------------------ | ----------- |
  34078. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34079. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34080. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34081. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34082. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34083. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34084. * | 7 | NEAREST_LINEAR | |
  34085. * | 8 | NEAREST_NEAREST | |
  34086. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34087. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34088. * | 11 | LINEAR_LINEAR | |
  34089. * | 12 | LINEAR_NEAREST | |
  34090. *
  34091. * > _mag_: magnification filter (close to the viewer)
  34092. * > _min_: minification filter (far from the viewer)
  34093. * > _mip_: filter used between mip map levels
  34094. *@param samplingMode Define the new sampling mode of the texture
  34095. */
  34096. updateSamplingMode(samplingMode: number): void;
  34097. /**
  34098. * Scales the texture if is `canRescale()`
  34099. * @param ratio the resize factor we want to use to rescale
  34100. */
  34101. scale(ratio: number): void;
  34102. /**
  34103. * Get if the texture can rescale.
  34104. */
  34105. get canRescale(): boolean;
  34106. /** @hidden */
  34107. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34108. /** @hidden */
  34109. _rebuild(): void;
  34110. /**
  34111. * Triggers the load sequence in delayed load mode.
  34112. */
  34113. delayLoad(): void;
  34114. /**
  34115. * Clones the texture.
  34116. * @returns the cloned texture
  34117. */
  34118. clone(): Nullable<BaseTexture>;
  34119. /**
  34120. * Get the texture underlying type (INT, FLOAT...)
  34121. */
  34122. get textureType(): number;
  34123. /**
  34124. * Get the texture underlying format (RGB, RGBA...)
  34125. */
  34126. get textureFormat(): number;
  34127. /**
  34128. * Indicates that textures need to be re-calculated for all materials
  34129. */
  34130. protected _markAllSubMeshesAsTexturesDirty(): void;
  34131. /**
  34132. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34133. * This will returns an RGBA array buffer containing either in values (0-255) or
  34134. * float values (0-1) depending of the underlying buffer type.
  34135. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34136. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34137. * @param buffer defines a user defined buffer to fill with data (can be null)
  34138. * @returns The Array buffer containing the pixels data.
  34139. */
  34140. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34141. /**
  34142. * Release and destroy the underlying lower level texture aka internalTexture.
  34143. */
  34144. releaseInternalTexture(): void;
  34145. /** @hidden */
  34146. get _lodTextureHigh(): Nullable<BaseTexture>;
  34147. /** @hidden */
  34148. get _lodTextureMid(): Nullable<BaseTexture>;
  34149. /** @hidden */
  34150. get _lodTextureLow(): Nullable<BaseTexture>;
  34151. /**
  34152. * Dispose the texture and release its associated resources.
  34153. */
  34154. dispose(): void;
  34155. /**
  34156. * Serialize the texture into a JSON representation that can be parsed later on.
  34157. * @returns the JSON representation of the texture
  34158. */
  34159. serialize(): any;
  34160. /**
  34161. * Helper function to be called back once a list of texture contains only ready textures.
  34162. * @param textures Define the list of textures to wait for
  34163. * @param callback Define the callback triggered once the entire list will be ready
  34164. */
  34165. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34166. private static _isScene;
  34167. }
  34168. }
  34169. declare module BABYLON {
  34170. /**
  34171. * Options to be used when creating an effect.
  34172. */
  34173. export interface IEffectCreationOptions {
  34174. /**
  34175. * Atrributes that will be used in the shader.
  34176. */
  34177. attributes: string[];
  34178. /**
  34179. * Uniform varible names that will be set in the shader.
  34180. */
  34181. uniformsNames: string[];
  34182. /**
  34183. * Uniform buffer variable names that will be set in the shader.
  34184. */
  34185. uniformBuffersNames: string[];
  34186. /**
  34187. * Sampler texture variable names that will be set in the shader.
  34188. */
  34189. samplers: string[];
  34190. /**
  34191. * Define statements that will be set in the shader.
  34192. */
  34193. defines: any;
  34194. /**
  34195. * Possible fallbacks for this effect to improve performance when needed.
  34196. */
  34197. fallbacks: Nullable<IEffectFallbacks>;
  34198. /**
  34199. * Callback that will be called when the shader is compiled.
  34200. */
  34201. onCompiled: Nullable<(effect: Effect) => void>;
  34202. /**
  34203. * Callback that will be called if an error occurs during shader compilation.
  34204. */
  34205. onError: Nullable<(effect: Effect, errors: string) => void>;
  34206. /**
  34207. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34208. */
  34209. indexParameters?: any;
  34210. /**
  34211. * Max number of lights that can be used in the shader.
  34212. */
  34213. maxSimultaneousLights?: number;
  34214. /**
  34215. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34216. */
  34217. transformFeedbackVaryings?: Nullable<string[]>;
  34218. /**
  34219. * 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
  34220. */
  34221. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34222. /**
  34223. * Is this effect rendering to several color attachments ?
  34224. */
  34225. multiTarget?: boolean;
  34226. }
  34227. /**
  34228. * Effect containing vertex and fragment shader that can be executed on an object.
  34229. */
  34230. export class Effect implements IDisposable {
  34231. /**
  34232. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34233. */
  34234. static ShadersRepository: string;
  34235. /**
  34236. * Enable logging of the shader code when a compilation error occurs
  34237. */
  34238. static LogShaderCodeOnCompilationError: boolean;
  34239. /**
  34240. * Name of the effect.
  34241. */
  34242. name: any;
  34243. /**
  34244. * String container all the define statements that should be set on the shader.
  34245. */
  34246. defines: string;
  34247. /**
  34248. * Callback that will be called when the shader is compiled.
  34249. */
  34250. onCompiled: Nullable<(effect: Effect) => void>;
  34251. /**
  34252. * Callback that will be called if an error occurs during shader compilation.
  34253. */
  34254. onError: Nullable<(effect: Effect, errors: string) => void>;
  34255. /**
  34256. * Callback that will be called when effect is bound.
  34257. */
  34258. onBind: Nullable<(effect: Effect) => void>;
  34259. /**
  34260. * Unique ID of the effect.
  34261. */
  34262. uniqueId: number;
  34263. /**
  34264. * Observable that will be called when the shader is compiled.
  34265. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34266. */
  34267. onCompileObservable: Observable<Effect>;
  34268. /**
  34269. * Observable that will be called if an error occurs during shader compilation.
  34270. */
  34271. onErrorObservable: Observable<Effect>;
  34272. /** @hidden */
  34273. _onBindObservable: Nullable<Observable<Effect>>;
  34274. /**
  34275. * @hidden
  34276. * Specifies if the effect was previously ready
  34277. */
  34278. _wasPreviouslyReady: boolean;
  34279. /**
  34280. * Observable that will be called when effect is bound.
  34281. */
  34282. get onBindObservable(): Observable<Effect>;
  34283. /** @hidden */
  34284. _bonesComputationForcedToCPU: boolean;
  34285. /** @hidden */
  34286. _multiTarget: boolean;
  34287. private static _uniqueIdSeed;
  34288. private _engine;
  34289. private _uniformBuffersNames;
  34290. private _uniformBuffersNamesList;
  34291. private _uniformsNames;
  34292. private _samplerList;
  34293. private _samplers;
  34294. private _isReady;
  34295. private _compilationError;
  34296. private _allFallbacksProcessed;
  34297. private _attributesNames;
  34298. private _attributes;
  34299. private _attributeLocationByName;
  34300. private _uniforms;
  34301. /**
  34302. * Key for the effect.
  34303. * @hidden
  34304. */
  34305. _key: string;
  34306. private _indexParameters;
  34307. private _fallbacks;
  34308. private _vertexSourceCode;
  34309. private _fragmentSourceCode;
  34310. private _vertexSourceCodeOverride;
  34311. private _fragmentSourceCodeOverride;
  34312. private _transformFeedbackVaryings;
  34313. /**
  34314. * Compiled shader to webGL program.
  34315. * @hidden
  34316. */
  34317. _pipelineContext: Nullable<IPipelineContext>;
  34318. private _valueCache;
  34319. private static _baseCache;
  34320. /**
  34321. * Instantiates an effect.
  34322. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34323. * @param baseName Name of the effect.
  34324. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34325. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34326. * @param samplers List of sampler variables that will be passed to the shader.
  34327. * @param engine Engine to be used to render the effect
  34328. * @param defines Define statements to be added to the shader.
  34329. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34330. * @param onCompiled Callback that will be called when the shader is compiled.
  34331. * @param onError Callback that will be called if an error occurs during shader compilation.
  34332. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34333. */
  34334. 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);
  34335. private _useFinalCode;
  34336. /**
  34337. * Unique key for this effect
  34338. */
  34339. get key(): string;
  34340. /**
  34341. * If the effect has been compiled and prepared.
  34342. * @returns if the effect is compiled and prepared.
  34343. */
  34344. isReady(): boolean;
  34345. private _isReadyInternal;
  34346. /**
  34347. * The engine the effect was initialized with.
  34348. * @returns the engine.
  34349. */
  34350. getEngine(): Engine;
  34351. /**
  34352. * The pipeline context for this effect
  34353. * @returns the associated pipeline context
  34354. */
  34355. getPipelineContext(): Nullable<IPipelineContext>;
  34356. /**
  34357. * The set of names of attribute variables for the shader.
  34358. * @returns An array of attribute names.
  34359. */
  34360. getAttributesNames(): string[];
  34361. /**
  34362. * Returns the attribute at the given index.
  34363. * @param index The index of the attribute.
  34364. * @returns The location of the attribute.
  34365. */
  34366. getAttributeLocation(index: number): number;
  34367. /**
  34368. * Returns the attribute based on the name of the variable.
  34369. * @param name of the attribute to look up.
  34370. * @returns the attribute location.
  34371. */
  34372. getAttributeLocationByName(name: string): number;
  34373. /**
  34374. * The number of attributes.
  34375. * @returns the numnber of attributes.
  34376. */
  34377. getAttributesCount(): number;
  34378. /**
  34379. * Gets the index of a uniform variable.
  34380. * @param uniformName of the uniform to look up.
  34381. * @returns the index.
  34382. */
  34383. getUniformIndex(uniformName: string): number;
  34384. /**
  34385. * Returns the attribute based on the name of the variable.
  34386. * @param uniformName of the uniform to look up.
  34387. * @returns the location of the uniform.
  34388. */
  34389. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34390. /**
  34391. * Returns an array of sampler variable names
  34392. * @returns The array of sampler variable names.
  34393. */
  34394. getSamplers(): string[];
  34395. /**
  34396. * Returns an array of uniform variable names
  34397. * @returns The array of uniform variable names.
  34398. */
  34399. getUniformNames(): string[];
  34400. /**
  34401. * Returns an array of uniform buffer variable names
  34402. * @returns The array of uniform buffer variable names.
  34403. */
  34404. getUniformBuffersNames(): string[];
  34405. /**
  34406. * Returns the index parameters used to create the effect
  34407. * @returns The index parameters object
  34408. */
  34409. getIndexParameters(): any;
  34410. /**
  34411. * The error from the last compilation.
  34412. * @returns the error string.
  34413. */
  34414. getCompilationError(): string;
  34415. /**
  34416. * Gets a boolean indicating that all fallbacks were used during compilation
  34417. * @returns true if all fallbacks were used
  34418. */
  34419. allFallbacksProcessed(): boolean;
  34420. /**
  34421. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34422. * @param func The callback to be used.
  34423. */
  34424. executeWhenCompiled(func: (effect: Effect) => void): void;
  34425. private _checkIsReady;
  34426. private _loadShader;
  34427. /**
  34428. * Gets the vertex shader source code of this effect
  34429. */
  34430. get vertexSourceCode(): string;
  34431. /**
  34432. * Gets the fragment shader source code of this effect
  34433. */
  34434. get fragmentSourceCode(): string;
  34435. /**
  34436. * Recompiles the webGL program
  34437. * @param vertexSourceCode The source code for the vertex shader.
  34438. * @param fragmentSourceCode The source code for the fragment shader.
  34439. * @param onCompiled Callback called when completed.
  34440. * @param onError Callback called on error.
  34441. * @hidden
  34442. */
  34443. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34444. /**
  34445. * Prepares the effect
  34446. * @hidden
  34447. */
  34448. _prepareEffect(): void;
  34449. private _getShaderCodeAndErrorLine;
  34450. private _processCompilationErrors;
  34451. /**
  34452. * Checks if the effect is supported. (Must be called after compilation)
  34453. */
  34454. get isSupported(): boolean;
  34455. /**
  34456. * Binds a texture to the engine to be used as output of the shader.
  34457. * @param channel Name of the output variable.
  34458. * @param texture Texture to bind.
  34459. * @hidden
  34460. */
  34461. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34462. /**
  34463. * Sets a texture on the engine to be used in the shader.
  34464. * @param channel Name of the sampler variable.
  34465. * @param texture Texture to set.
  34466. */
  34467. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34468. /**
  34469. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34470. * @param channel Name of the sampler variable.
  34471. * @param texture Texture to set.
  34472. */
  34473. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34474. /**
  34475. * Sets an array of textures on the engine to be used in the shader.
  34476. * @param channel Name of the variable.
  34477. * @param textures Textures to set.
  34478. */
  34479. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34480. /**
  34481. * 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)
  34482. * @param channel Name of the sampler variable.
  34483. * @param postProcess Post process to get the input texture from.
  34484. */
  34485. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34486. /**
  34487. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34488. * 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)
  34489. * @param channel Name of the sampler variable.
  34490. * @param postProcess Post process to get the output texture from.
  34491. */
  34492. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34493. /** @hidden */
  34494. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34495. /** @hidden */
  34496. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34497. /** @hidden */
  34498. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34499. /** @hidden */
  34500. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34501. /**
  34502. * Binds a buffer to a uniform.
  34503. * @param buffer Buffer to bind.
  34504. * @param name Name of the uniform variable to bind to.
  34505. */
  34506. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34507. /**
  34508. * Binds block to a uniform.
  34509. * @param blockName Name of the block to bind.
  34510. * @param index Index to bind.
  34511. */
  34512. bindUniformBlock(blockName: string, index: number): void;
  34513. /**
  34514. * Sets an interger value on a uniform variable.
  34515. * @param uniformName Name of the variable.
  34516. * @param value Value to be set.
  34517. * @returns this effect.
  34518. */
  34519. setInt(uniformName: string, value: number): Effect;
  34520. /**
  34521. * Sets an int array on a uniform variable.
  34522. * @param uniformName Name of the variable.
  34523. * @param array array to be set.
  34524. * @returns this effect.
  34525. */
  34526. setIntArray(uniformName: string, array: Int32Array): Effect;
  34527. /**
  34528. * 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)
  34529. * @param uniformName Name of the variable.
  34530. * @param array array to be set.
  34531. * @returns this effect.
  34532. */
  34533. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34534. /**
  34535. * 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)
  34536. * @param uniformName Name of the variable.
  34537. * @param array array to be set.
  34538. * @returns this effect.
  34539. */
  34540. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34541. /**
  34542. * 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)
  34543. * @param uniformName Name of the variable.
  34544. * @param array array to be set.
  34545. * @returns this effect.
  34546. */
  34547. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34548. /**
  34549. * Sets an float array on a uniform variable.
  34550. * @param uniformName Name of the variable.
  34551. * @param array array to be set.
  34552. * @returns this effect.
  34553. */
  34554. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34555. /**
  34556. * 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)
  34557. * @param uniformName Name of the variable.
  34558. * @param array array to be set.
  34559. * @returns this effect.
  34560. */
  34561. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34562. /**
  34563. * 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)
  34564. * @param uniformName Name of the variable.
  34565. * @param array array to be set.
  34566. * @returns this effect.
  34567. */
  34568. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34569. /**
  34570. * 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)
  34571. * @param uniformName Name of the variable.
  34572. * @param array array to be set.
  34573. * @returns this effect.
  34574. */
  34575. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34576. /**
  34577. * Sets an array on a uniform variable.
  34578. * @param uniformName Name of the variable.
  34579. * @param array array to be set.
  34580. * @returns this effect.
  34581. */
  34582. setArray(uniformName: string, array: number[]): Effect;
  34583. /**
  34584. * 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)
  34585. * @param uniformName Name of the variable.
  34586. * @param array array to be set.
  34587. * @returns this effect.
  34588. */
  34589. setArray2(uniformName: string, array: number[]): Effect;
  34590. /**
  34591. * 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)
  34592. * @param uniformName Name of the variable.
  34593. * @param array array to be set.
  34594. * @returns this effect.
  34595. */
  34596. setArray3(uniformName: string, array: number[]): Effect;
  34597. /**
  34598. * 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)
  34599. * @param uniformName Name of the variable.
  34600. * @param array array to be set.
  34601. * @returns this effect.
  34602. */
  34603. setArray4(uniformName: string, array: number[]): Effect;
  34604. /**
  34605. * Sets matrices on a uniform variable.
  34606. * @param uniformName Name of the variable.
  34607. * @param matrices matrices to be set.
  34608. * @returns this effect.
  34609. */
  34610. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34611. /**
  34612. * Sets matrix on a uniform variable.
  34613. * @param uniformName Name of the variable.
  34614. * @param matrix matrix to be set.
  34615. * @returns this effect.
  34616. */
  34617. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34618. /**
  34619. * 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)
  34620. * @param uniformName Name of the variable.
  34621. * @param matrix matrix to be set.
  34622. * @returns this effect.
  34623. */
  34624. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34625. /**
  34626. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34627. * @param uniformName Name of the variable.
  34628. * @param matrix matrix to be set.
  34629. * @returns this effect.
  34630. */
  34631. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34632. /**
  34633. * Sets a float on a uniform variable.
  34634. * @param uniformName Name of the variable.
  34635. * @param value value to be set.
  34636. * @returns this effect.
  34637. */
  34638. setFloat(uniformName: string, value: number): Effect;
  34639. /**
  34640. * Sets a boolean on a uniform variable.
  34641. * @param uniformName Name of the variable.
  34642. * @param bool value to be set.
  34643. * @returns this effect.
  34644. */
  34645. setBool(uniformName: string, bool: boolean): Effect;
  34646. /**
  34647. * Sets a Vector2 on a uniform variable.
  34648. * @param uniformName Name of the variable.
  34649. * @param vector2 vector2 to be set.
  34650. * @returns this effect.
  34651. */
  34652. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34653. /**
  34654. * Sets a float2 on a uniform variable.
  34655. * @param uniformName Name of the variable.
  34656. * @param x First float in float2.
  34657. * @param y Second float in float2.
  34658. * @returns this effect.
  34659. */
  34660. setFloat2(uniformName: string, x: number, y: number): Effect;
  34661. /**
  34662. * Sets a Vector3 on a uniform variable.
  34663. * @param uniformName Name of the variable.
  34664. * @param vector3 Value to be set.
  34665. * @returns this effect.
  34666. */
  34667. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34668. /**
  34669. * Sets a float3 on a uniform variable.
  34670. * @param uniformName Name of the variable.
  34671. * @param x First float in float3.
  34672. * @param y Second float in float3.
  34673. * @param z Third float in float3.
  34674. * @returns this effect.
  34675. */
  34676. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34677. /**
  34678. * Sets a Vector4 on a uniform variable.
  34679. * @param uniformName Name of the variable.
  34680. * @param vector4 Value to be set.
  34681. * @returns this effect.
  34682. */
  34683. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34684. /**
  34685. * Sets a float4 on a uniform variable.
  34686. * @param uniformName Name of the variable.
  34687. * @param x First float in float4.
  34688. * @param y Second float in float4.
  34689. * @param z Third float in float4.
  34690. * @param w Fourth float in float4.
  34691. * @returns this effect.
  34692. */
  34693. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34694. /**
  34695. * Sets a Color3 on a uniform variable.
  34696. * @param uniformName Name of the variable.
  34697. * @param color3 Value to be set.
  34698. * @returns this effect.
  34699. */
  34700. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34701. /**
  34702. * Sets a Color4 on a uniform variable.
  34703. * @param uniformName Name of the variable.
  34704. * @param color3 Value to be set.
  34705. * @param alpha Alpha value to be set.
  34706. * @returns this effect.
  34707. */
  34708. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34709. /**
  34710. * Sets a Color4 on a uniform variable
  34711. * @param uniformName defines the name of the variable
  34712. * @param color4 defines the value to be set
  34713. * @returns this effect.
  34714. */
  34715. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34716. /** Release all associated resources */
  34717. dispose(): void;
  34718. /**
  34719. * This function will add a new shader to the shader store
  34720. * @param name the name of the shader
  34721. * @param pixelShader optional pixel shader content
  34722. * @param vertexShader optional vertex shader content
  34723. */
  34724. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34725. /**
  34726. * Store of each shader (The can be looked up using effect.key)
  34727. */
  34728. static ShadersStore: {
  34729. [key: string]: string;
  34730. };
  34731. /**
  34732. * Store of each included file for a shader (The can be looked up using effect.key)
  34733. */
  34734. static IncludesShadersStore: {
  34735. [key: string]: string;
  34736. };
  34737. /**
  34738. * Resets the cache of effects.
  34739. */
  34740. static ResetCache(): void;
  34741. }
  34742. }
  34743. declare module BABYLON {
  34744. /**
  34745. * Interface used to describe the capabilities of the engine relatively to the current browser
  34746. */
  34747. export interface EngineCapabilities {
  34748. /** Maximum textures units per fragment shader */
  34749. maxTexturesImageUnits: number;
  34750. /** Maximum texture units per vertex shader */
  34751. maxVertexTextureImageUnits: number;
  34752. /** Maximum textures units in the entire pipeline */
  34753. maxCombinedTexturesImageUnits: number;
  34754. /** Maximum texture size */
  34755. maxTextureSize: number;
  34756. /** Maximum texture samples */
  34757. maxSamples?: number;
  34758. /** Maximum cube texture size */
  34759. maxCubemapTextureSize: number;
  34760. /** Maximum render texture size */
  34761. maxRenderTextureSize: number;
  34762. /** Maximum number of vertex attributes */
  34763. maxVertexAttribs: number;
  34764. /** Maximum number of varyings */
  34765. maxVaryingVectors: number;
  34766. /** Maximum number of uniforms per vertex shader */
  34767. maxVertexUniformVectors: number;
  34768. /** Maximum number of uniforms per fragment shader */
  34769. maxFragmentUniformVectors: number;
  34770. /** Defines if standard derivates (dx/dy) are supported */
  34771. standardDerivatives: boolean;
  34772. /** Defines if s3tc texture compression is supported */
  34773. s3tc?: WEBGL_compressed_texture_s3tc;
  34774. /** Defines if pvrtc texture compression is supported */
  34775. pvrtc: any;
  34776. /** Defines if etc1 texture compression is supported */
  34777. etc1: any;
  34778. /** Defines if etc2 texture compression is supported */
  34779. etc2: any;
  34780. /** Defines if astc texture compression is supported */
  34781. astc: any;
  34782. /** Defines if float textures are supported */
  34783. textureFloat: boolean;
  34784. /** Defines if vertex array objects are supported */
  34785. vertexArrayObject: boolean;
  34786. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34787. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34788. /** Gets the maximum level of anisotropy supported */
  34789. maxAnisotropy: number;
  34790. /** Defines if instancing is supported */
  34791. instancedArrays: boolean;
  34792. /** Defines if 32 bits indices are supported */
  34793. uintIndices: boolean;
  34794. /** Defines if high precision shaders are supported */
  34795. highPrecisionShaderSupported: boolean;
  34796. /** Defines if depth reading in the fragment shader is supported */
  34797. fragmentDepthSupported: boolean;
  34798. /** Defines if float texture linear filtering is supported*/
  34799. textureFloatLinearFiltering: boolean;
  34800. /** Defines if rendering to float textures is supported */
  34801. textureFloatRender: boolean;
  34802. /** Defines if half float textures are supported*/
  34803. textureHalfFloat: boolean;
  34804. /** Defines if half float texture linear filtering is supported*/
  34805. textureHalfFloatLinearFiltering: boolean;
  34806. /** Defines if rendering to half float textures is supported */
  34807. textureHalfFloatRender: boolean;
  34808. /** Defines if textureLOD shader command is supported */
  34809. textureLOD: boolean;
  34810. /** Defines if draw buffers extension is supported */
  34811. drawBuffersExtension: boolean;
  34812. /** Defines if depth textures are supported */
  34813. depthTextureExtension: boolean;
  34814. /** Defines if float color buffer are supported */
  34815. colorBufferFloat: boolean;
  34816. /** Gets disjoint timer query extension (null if not supported) */
  34817. timerQuery?: EXT_disjoint_timer_query;
  34818. /** Defines if timestamp can be used with timer query */
  34819. canUseTimestampForTimerQuery: boolean;
  34820. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34821. multiview?: any;
  34822. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34823. oculusMultiview?: any;
  34824. /** Function used to let the system compiles shaders in background */
  34825. parallelShaderCompile?: {
  34826. COMPLETION_STATUS_KHR: number;
  34827. };
  34828. /** Max number of texture samples for MSAA */
  34829. maxMSAASamples: number;
  34830. /** Defines if the blend min max extension is supported */
  34831. blendMinMax: boolean;
  34832. }
  34833. }
  34834. declare module BABYLON {
  34835. /**
  34836. * @hidden
  34837. **/
  34838. export class DepthCullingState {
  34839. private _isDepthTestDirty;
  34840. private _isDepthMaskDirty;
  34841. private _isDepthFuncDirty;
  34842. private _isCullFaceDirty;
  34843. private _isCullDirty;
  34844. private _isZOffsetDirty;
  34845. private _isFrontFaceDirty;
  34846. private _depthTest;
  34847. private _depthMask;
  34848. private _depthFunc;
  34849. private _cull;
  34850. private _cullFace;
  34851. private _zOffset;
  34852. private _frontFace;
  34853. /**
  34854. * Initializes the state.
  34855. */
  34856. constructor();
  34857. get isDirty(): boolean;
  34858. get zOffset(): number;
  34859. set zOffset(value: number);
  34860. get cullFace(): Nullable<number>;
  34861. set cullFace(value: Nullable<number>);
  34862. get cull(): Nullable<boolean>;
  34863. set cull(value: Nullable<boolean>);
  34864. get depthFunc(): Nullable<number>;
  34865. set depthFunc(value: Nullable<number>);
  34866. get depthMask(): boolean;
  34867. set depthMask(value: boolean);
  34868. get depthTest(): boolean;
  34869. set depthTest(value: boolean);
  34870. get frontFace(): Nullable<number>;
  34871. set frontFace(value: Nullable<number>);
  34872. reset(): void;
  34873. apply(gl: WebGLRenderingContext): void;
  34874. }
  34875. }
  34876. declare module BABYLON {
  34877. /**
  34878. * @hidden
  34879. **/
  34880. export class StencilState {
  34881. /** 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 */
  34882. static readonly ALWAYS: number;
  34883. /** Passed to stencilOperation to specify that stencil value must be kept */
  34884. static readonly KEEP: number;
  34885. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34886. static readonly REPLACE: number;
  34887. private _isStencilTestDirty;
  34888. private _isStencilMaskDirty;
  34889. private _isStencilFuncDirty;
  34890. private _isStencilOpDirty;
  34891. private _stencilTest;
  34892. private _stencilMask;
  34893. private _stencilFunc;
  34894. private _stencilFuncRef;
  34895. private _stencilFuncMask;
  34896. private _stencilOpStencilFail;
  34897. private _stencilOpDepthFail;
  34898. private _stencilOpStencilDepthPass;
  34899. get isDirty(): boolean;
  34900. get stencilFunc(): number;
  34901. set stencilFunc(value: number);
  34902. get stencilFuncRef(): number;
  34903. set stencilFuncRef(value: number);
  34904. get stencilFuncMask(): number;
  34905. set stencilFuncMask(value: number);
  34906. get stencilOpStencilFail(): number;
  34907. set stencilOpStencilFail(value: number);
  34908. get stencilOpDepthFail(): number;
  34909. set stencilOpDepthFail(value: number);
  34910. get stencilOpStencilDepthPass(): number;
  34911. set stencilOpStencilDepthPass(value: number);
  34912. get stencilMask(): number;
  34913. set stencilMask(value: number);
  34914. get stencilTest(): boolean;
  34915. set stencilTest(value: boolean);
  34916. constructor();
  34917. reset(): void;
  34918. apply(gl: WebGLRenderingContext): void;
  34919. }
  34920. }
  34921. declare module BABYLON {
  34922. /**
  34923. * @hidden
  34924. **/
  34925. export class AlphaState {
  34926. private _isAlphaBlendDirty;
  34927. private _isBlendFunctionParametersDirty;
  34928. private _isBlendEquationParametersDirty;
  34929. private _isBlendConstantsDirty;
  34930. private _alphaBlend;
  34931. private _blendFunctionParameters;
  34932. private _blendEquationParameters;
  34933. private _blendConstants;
  34934. /**
  34935. * Initializes the state.
  34936. */
  34937. constructor();
  34938. get isDirty(): boolean;
  34939. get alphaBlend(): boolean;
  34940. set alphaBlend(value: boolean);
  34941. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34942. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34943. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34944. reset(): void;
  34945. apply(gl: WebGLRenderingContext): void;
  34946. }
  34947. }
  34948. declare module BABYLON {
  34949. /** @hidden */
  34950. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34951. attributeProcessor(attribute: string): string;
  34952. varyingProcessor(varying: string, isFragment: boolean): string;
  34953. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34954. }
  34955. }
  34956. declare module BABYLON {
  34957. /**
  34958. * Interface for attribute information associated with buffer instanciation
  34959. */
  34960. export interface InstancingAttributeInfo {
  34961. /**
  34962. * Name of the GLSL attribute
  34963. * if attribute index is not specified, this is used to retrieve the index from the effect
  34964. */
  34965. attributeName: string;
  34966. /**
  34967. * Index/offset of the attribute in the vertex shader
  34968. * if not specified, this will be computes from the name.
  34969. */
  34970. index?: number;
  34971. /**
  34972. * size of the attribute, 1, 2, 3 or 4
  34973. */
  34974. attributeSize: number;
  34975. /**
  34976. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34977. */
  34978. offset: number;
  34979. /**
  34980. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34981. * default to 1
  34982. */
  34983. divisor?: number;
  34984. /**
  34985. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34986. * default is FLOAT
  34987. */
  34988. attributeType?: number;
  34989. /**
  34990. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34991. */
  34992. normalized?: boolean;
  34993. }
  34994. }
  34995. declare module BABYLON {
  34996. interface ThinEngine {
  34997. /**
  34998. * Update a video texture
  34999. * @param texture defines the texture to update
  35000. * @param video defines the video element to use
  35001. * @param invertY defines if data must be stored with Y axis inverted
  35002. */
  35003. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35004. }
  35005. }
  35006. declare module BABYLON {
  35007. interface ThinEngine {
  35008. /**
  35009. * Creates a dynamic texture
  35010. * @param width defines the width of the texture
  35011. * @param height defines the height of the texture
  35012. * @param generateMipMaps defines if the engine should generate the mip levels
  35013. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35014. * @returns the dynamic texture inside an InternalTexture
  35015. */
  35016. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35017. /**
  35018. * Update the content of a dynamic texture
  35019. * @param texture defines the texture to update
  35020. * @param canvas defines the canvas containing the source
  35021. * @param invertY defines if data must be stored with Y axis inverted
  35022. * @param premulAlpha defines if alpha is stored as premultiplied
  35023. * @param format defines the format of the data
  35024. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35025. */
  35026. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35027. }
  35028. }
  35029. declare module BABYLON {
  35030. /**
  35031. * Settings for finer control over video usage
  35032. */
  35033. export interface VideoTextureSettings {
  35034. /**
  35035. * Applies `autoplay` to video, if specified
  35036. */
  35037. autoPlay?: boolean;
  35038. /**
  35039. * Applies `loop` to video, if specified
  35040. */
  35041. loop?: boolean;
  35042. /**
  35043. * Automatically updates internal texture from video at every frame in the render loop
  35044. */
  35045. autoUpdateTexture: boolean;
  35046. /**
  35047. * Image src displayed during the video loading or until the user interacts with the video.
  35048. */
  35049. poster?: string;
  35050. }
  35051. /**
  35052. * If you want to display a video in your scene, this is the special texture for that.
  35053. * This special texture works similar to other textures, with the exception of a few parameters.
  35054. * @see https://doc.babylonjs.com/how_to/video_texture
  35055. */
  35056. export class VideoTexture extends Texture {
  35057. /**
  35058. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35059. */
  35060. readonly autoUpdateTexture: boolean;
  35061. /**
  35062. * The video instance used by the texture internally
  35063. */
  35064. readonly video: HTMLVideoElement;
  35065. private _onUserActionRequestedObservable;
  35066. /**
  35067. * Event triggerd when a dom action is required by the user to play the video.
  35068. * This happens due to recent changes in browser policies preventing video to auto start.
  35069. */
  35070. get onUserActionRequestedObservable(): Observable<Texture>;
  35071. private _generateMipMaps;
  35072. private _stillImageCaptured;
  35073. private _displayingPosterTexture;
  35074. private _settings;
  35075. private _createInternalTextureOnEvent;
  35076. private _frameId;
  35077. private _currentSrc;
  35078. /**
  35079. * Creates a video texture.
  35080. * If you want to display a video in your scene, this is the special texture for that.
  35081. * This special texture works similar to other textures, with the exception of a few parameters.
  35082. * @see https://doc.babylonjs.com/how_to/video_texture
  35083. * @param name optional name, will detect from video source, if not defined
  35084. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35085. * @param scene is obviously the current scene.
  35086. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35087. * @param invertY is false by default but can be used to invert video on Y axis
  35088. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35089. * @param settings allows finer control over video usage
  35090. */
  35091. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35092. private _getName;
  35093. private _getVideo;
  35094. private _createInternalTexture;
  35095. private reset;
  35096. /**
  35097. * @hidden Internal method to initiate `update`.
  35098. */
  35099. _rebuild(): void;
  35100. /**
  35101. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35102. */
  35103. update(): void;
  35104. /**
  35105. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35106. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35107. */
  35108. updateTexture(isVisible: boolean): void;
  35109. protected _updateInternalTexture: () => void;
  35110. /**
  35111. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35112. * @param url New url.
  35113. */
  35114. updateURL(url: string): void;
  35115. /**
  35116. * Clones the texture.
  35117. * @returns the cloned texture
  35118. */
  35119. clone(): VideoTexture;
  35120. /**
  35121. * Dispose the texture and release its associated resources.
  35122. */
  35123. dispose(): void;
  35124. /**
  35125. * Creates a video texture straight from a stream.
  35126. * @param scene Define the scene the texture should be created in
  35127. * @param stream Define the stream the texture should be created from
  35128. * @returns The created video texture as a promise
  35129. */
  35130. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35131. /**
  35132. * Creates a video texture straight from your WebCam video feed.
  35133. * @param scene Define the scene the texture should be created in
  35134. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35135. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35136. * @returns The created video texture as a promise
  35137. */
  35138. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35139. minWidth: number;
  35140. maxWidth: number;
  35141. minHeight: number;
  35142. maxHeight: number;
  35143. deviceId: string;
  35144. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35145. /**
  35146. * Creates a video texture straight from your WebCam video feed.
  35147. * @param scene Define the scene the texture should be created in
  35148. * @param onReady Define a callback to triggered once the texture will be ready
  35149. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35150. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35151. */
  35152. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35153. minWidth: number;
  35154. maxWidth: number;
  35155. minHeight: number;
  35156. maxHeight: number;
  35157. deviceId: string;
  35158. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35159. }
  35160. }
  35161. declare module BABYLON {
  35162. /**
  35163. * Defines the interface used by objects working like Scene
  35164. * @hidden
  35165. */
  35166. export interface ISceneLike {
  35167. _addPendingData(data: any): void;
  35168. _removePendingData(data: any): void;
  35169. offlineProvider: IOfflineProvider;
  35170. }
  35171. /**
  35172. * Information about the current host
  35173. */
  35174. export interface HostInformation {
  35175. /**
  35176. * Defines if the current host is a mobile
  35177. */
  35178. isMobile: boolean;
  35179. }
  35180. /** Interface defining initialization parameters for Engine class */
  35181. export interface EngineOptions extends WebGLContextAttributes {
  35182. /**
  35183. * Defines if the engine should no exceed a specified device ratio
  35184. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35185. */
  35186. limitDeviceRatio?: number;
  35187. /**
  35188. * Defines if webvr should be enabled automatically
  35189. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35190. */
  35191. autoEnableWebVR?: boolean;
  35192. /**
  35193. * Defines if webgl2 should be turned off even if supported
  35194. * @see https://doc.babylonjs.com/features/webgl2
  35195. */
  35196. disableWebGL2Support?: boolean;
  35197. /**
  35198. * Defines if webaudio should be initialized as well
  35199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35200. */
  35201. audioEngine?: boolean;
  35202. /**
  35203. * Defines if animations should run using a deterministic lock step
  35204. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35205. */
  35206. deterministicLockstep?: boolean;
  35207. /** Defines the maximum steps to use with deterministic lock step mode */
  35208. lockstepMaxSteps?: number;
  35209. /** Defines the seconds between each deterministic lock step */
  35210. timeStep?: number;
  35211. /**
  35212. * Defines that engine should ignore context lost events
  35213. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35214. */
  35215. doNotHandleContextLost?: boolean;
  35216. /**
  35217. * Defines that engine should ignore modifying touch action attribute and style
  35218. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35219. */
  35220. doNotHandleTouchAction?: boolean;
  35221. /**
  35222. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35223. */
  35224. useHighPrecisionFloats?: boolean;
  35225. /**
  35226. * Make the canvas XR Compatible for XR sessions
  35227. */
  35228. xrCompatible?: boolean;
  35229. /**
  35230. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35231. */
  35232. useHighPrecisionMatrix?: boolean;
  35233. }
  35234. /**
  35235. * The base engine class (root of all engines)
  35236. */
  35237. export class ThinEngine {
  35238. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35239. static ExceptionList: ({
  35240. key: string;
  35241. capture: string;
  35242. captureConstraint: number;
  35243. targets: string[];
  35244. } | {
  35245. key: string;
  35246. capture: null;
  35247. captureConstraint: null;
  35248. targets: string[];
  35249. })[];
  35250. /** @hidden */
  35251. static _TextureLoaders: IInternalTextureLoader[];
  35252. /**
  35253. * Returns the current npm package of the sdk
  35254. */
  35255. static get NpmPackage(): string;
  35256. /**
  35257. * Returns the current version of the framework
  35258. */
  35259. static get Version(): string;
  35260. /**
  35261. * Returns a string describing the current engine
  35262. */
  35263. get description(): string;
  35264. /**
  35265. * Gets or sets the epsilon value used by collision engine
  35266. */
  35267. static CollisionsEpsilon: number;
  35268. /**
  35269. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35270. */
  35271. static get ShadersRepository(): string;
  35272. static set ShadersRepository(value: string);
  35273. /** @hidden */
  35274. _shaderProcessor: IShaderProcessor;
  35275. /**
  35276. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35277. */
  35278. forcePOTTextures: boolean;
  35279. /**
  35280. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35281. */
  35282. isFullscreen: boolean;
  35283. /**
  35284. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35285. */
  35286. cullBackFaces: boolean;
  35287. /**
  35288. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35289. */
  35290. renderEvenInBackground: boolean;
  35291. /**
  35292. * Gets or sets a boolean indicating that cache can be kept between frames
  35293. */
  35294. preventCacheWipeBetweenFrames: boolean;
  35295. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35296. validateShaderPrograms: boolean;
  35297. /**
  35298. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35299. * This can provide greater z depth for distant objects.
  35300. */
  35301. useReverseDepthBuffer: boolean;
  35302. /**
  35303. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35304. */
  35305. disableUniformBuffers: boolean;
  35306. /** @hidden */
  35307. _uniformBuffers: UniformBuffer[];
  35308. /**
  35309. * Gets a boolean indicating that the engine supports uniform buffers
  35310. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35311. */
  35312. get supportsUniformBuffers(): boolean;
  35313. /** @hidden */
  35314. _gl: WebGLRenderingContext;
  35315. /** @hidden */
  35316. _webGLVersion: number;
  35317. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35318. protected _windowIsBackground: boolean;
  35319. protected _creationOptions: EngineOptions;
  35320. protected _highPrecisionShadersAllowed: boolean;
  35321. /** @hidden */
  35322. get _shouldUseHighPrecisionShader(): boolean;
  35323. /**
  35324. * Gets a boolean indicating that only power of 2 textures are supported
  35325. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35326. */
  35327. get needPOTTextures(): boolean;
  35328. /** @hidden */
  35329. _badOS: boolean;
  35330. /** @hidden */
  35331. _badDesktopOS: boolean;
  35332. private _hardwareScalingLevel;
  35333. /** @hidden */
  35334. _caps: EngineCapabilities;
  35335. private _isStencilEnable;
  35336. private _glVersion;
  35337. private _glRenderer;
  35338. private _glVendor;
  35339. /** @hidden */
  35340. _videoTextureSupported: boolean;
  35341. protected _renderingQueueLaunched: boolean;
  35342. protected _activeRenderLoops: (() => void)[];
  35343. /**
  35344. * Observable signaled when a context lost event is raised
  35345. */
  35346. onContextLostObservable: Observable<ThinEngine>;
  35347. /**
  35348. * Observable signaled when a context restored event is raised
  35349. */
  35350. onContextRestoredObservable: Observable<ThinEngine>;
  35351. private _onContextLost;
  35352. private _onContextRestored;
  35353. protected _contextWasLost: boolean;
  35354. /** @hidden */
  35355. _doNotHandleContextLost: boolean;
  35356. /**
  35357. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35359. */
  35360. get doNotHandleContextLost(): boolean;
  35361. set doNotHandleContextLost(value: boolean);
  35362. /**
  35363. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35364. */
  35365. disableVertexArrayObjects: boolean;
  35366. /** @hidden */
  35367. protected _colorWrite: boolean;
  35368. /** @hidden */
  35369. protected _colorWriteChanged: boolean;
  35370. /** @hidden */
  35371. protected _depthCullingState: DepthCullingState;
  35372. /** @hidden */
  35373. protected _stencilState: StencilState;
  35374. /** @hidden */
  35375. _alphaState: AlphaState;
  35376. /** @hidden */
  35377. _alphaMode: number;
  35378. /** @hidden */
  35379. _alphaEquation: number;
  35380. /** @hidden */
  35381. _internalTexturesCache: InternalTexture[];
  35382. /** @hidden */
  35383. protected _activeChannel: number;
  35384. private _currentTextureChannel;
  35385. /** @hidden */
  35386. protected _boundTexturesCache: {
  35387. [key: string]: Nullable<InternalTexture>;
  35388. };
  35389. /** @hidden */
  35390. protected _currentEffect: Nullable<Effect>;
  35391. /** @hidden */
  35392. protected _currentProgram: Nullable<WebGLProgram>;
  35393. private _compiledEffects;
  35394. private _vertexAttribArraysEnabled;
  35395. /** @hidden */
  35396. protected _cachedViewport: Nullable<IViewportLike>;
  35397. private _cachedVertexArrayObject;
  35398. /** @hidden */
  35399. protected _cachedVertexBuffers: any;
  35400. /** @hidden */
  35401. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35402. /** @hidden */
  35403. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35404. /** @hidden */
  35405. _currentRenderTarget: Nullable<InternalTexture>;
  35406. private _uintIndicesCurrentlySet;
  35407. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35408. /** @hidden */
  35409. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35410. /** @hidden */
  35411. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35412. private _currentBufferPointers;
  35413. private _currentInstanceLocations;
  35414. private _currentInstanceBuffers;
  35415. private _textureUnits;
  35416. /** @hidden */
  35417. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35418. /** @hidden */
  35419. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35420. /** @hidden */
  35421. _boundRenderFunction: any;
  35422. private _vaoRecordInProgress;
  35423. private _mustWipeVertexAttributes;
  35424. private _emptyTexture;
  35425. private _emptyCubeTexture;
  35426. private _emptyTexture3D;
  35427. private _emptyTexture2DArray;
  35428. /** @hidden */
  35429. _frameHandler: number;
  35430. private _nextFreeTextureSlots;
  35431. private _maxSimultaneousTextures;
  35432. private _activeRequests;
  35433. /** @hidden */
  35434. _transformTextureUrl: Nullable<(url: string) => string>;
  35435. /**
  35436. * Gets information about the current host
  35437. */
  35438. hostInformation: HostInformation;
  35439. protected get _supportsHardwareTextureRescaling(): boolean;
  35440. private _framebufferDimensionsObject;
  35441. /**
  35442. * sets the object from which width and height will be taken from when getting render width and height
  35443. * Will fallback to the gl object
  35444. * @param dimensions the framebuffer width and height that will be used.
  35445. */
  35446. set framebufferDimensionsObject(dimensions: Nullable<{
  35447. framebufferWidth: number;
  35448. framebufferHeight: number;
  35449. }>);
  35450. /**
  35451. * Gets the current viewport
  35452. */
  35453. get currentViewport(): Nullable<IViewportLike>;
  35454. /**
  35455. * Gets the default empty texture
  35456. */
  35457. get emptyTexture(): InternalTexture;
  35458. /**
  35459. * Gets the default empty 3D texture
  35460. */
  35461. get emptyTexture3D(): InternalTexture;
  35462. /**
  35463. * Gets the default empty 2D array texture
  35464. */
  35465. get emptyTexture2DArray(): InternalTexture;
  35466. /**
  35467. * Gets the default empty cube texture
  35468. */
  35469. get emptyCubeTexture(): InternalTexture;
  35470. /**
  35471. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35472. */
  35473. readonly premultipliedAlpha: boolean;
  35474. /**
  35475. * Observable event triggered before each texture is initialized
  35476. */
  35477. onBeforeTextureInitObservable: Observable<Texture>;
  35478. /**
  35479. * Creates a new engine
  35480. * @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
  35481. * @param antialias defines enable antialiasing (default: false)
  35482. * @param options defines further options to be sent to the getContext() function
  35483. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35484. */
  35485. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35486. private _rebuildInternalTextures;
  35487. private _rebuildEffects;
  35488. /**
  35489. * Gets a boolean indicating if all created effects are ready
  35490. * @returns true if all effects are ready
  35491. */
  35492. areAllEffectsReady(): boolean;
  35493. protected _rebuildBuffers(): void;
  35494. protected _initGLContext(): void;
  35495. /**
  35496. * Gets version of the current webGL context
  35497. */
  35498. get webGLVersion(): number;
  35499. /**
  35500. * Gets a string identifying the name of the class
  35501. * @returns "Engine" string
  35502. */
  35503. getClassName(): string;
  35504. /**
  35505. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35506. */
  35507. get isStencilEnable(): boolean;
  35508. /** @hidden */
  35509. _prepareWorkingCanvas(): void;
  35510. /**
  35511. * Reset the texture cache to empty state
  35512. */
  35513. resetTextureCache(): void;
  35514. /**
  35515. * Gets an object containing information about the current webGL context
  35516. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35517. */
  35518. getGlInfo(): {
  35519. vendor: string;
  35520. renderer: string;
  35521. version: string;
  35522. };
  35523. /**
  35524. * Defines the hardware scaling level.
  35525. * By default the hardware scaling level is computed from the window device ratio.
  35526. * 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.
  35527. * @param level defines the level to use
  35528. */
  35529. setHardwareScalingLevel(level: number): void;
  35530. /**
  35531. * Gets the current hardware scaling level.
  35532. * By default the hardware scaling level is computed from the window device ratio.
  35533. * 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.
  35534. * @returns a number indicating the current hardware scaling level
  35535. */
  35536. getHardwareScalingLevel(): number;
  35537. /**
  35538. * Gets the list of loaded textures
  35539. * @returns an array containing all loaded textures
  35540. */
  35541. getLoadedTexturesCache(): InternalTexture[];
  35542. /**
  35543. * Gets the object containing all engine capabilities
  35544. * @returns the EngineCapabilities object
  35545. */
  35546. getCaps(): EngineCapabilities;
  35547. /**
  35548. * stop executing a render loop function and remove it from the execution array
  35549. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35550. */
  35551. stopRenderLoop(renderFunction?: () => void): void;
  35552. /** @hidden */
  35553. _renderLoop(): void;
  35554. /**
  35555. * Gets the HTML canvas attached with the current webGL context
  35556. * @returns a HTML canvas
  35557. */
  35558. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35559. /**
  35560. * Gets host window
  35561. * @returns the host window object
  35562. */
  35563. getHostWindow(): Nullable<Window>;
  35564. /**
  35565. * Gets the current render width
  35566. * @param useScreen defines if screen size must be used (or the current render target if any)
  35567. * @returns a number defining the current render width
  35568. */
  35569. getRenderWidth(useScreen?: boolean): number;
  35570. /**
  35571. * Gets the current render height
  35572. * @param useScreen defines if screen size must be used (or the current render target if any)
  35573. * @returns a number defining the current render height
  35574. */
  35575. getRenderHeight(useScreen?: boolean): number;
  35576. /**
  35577. * Can be used to override the current requestAnimationFrame requester.
  35578. * @hidden
  35579. */
  35580. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35581. /**
  35582. * Register and execute a render loop. The engine can have more than one render function
  35583. * @param renderFunction defines the function to continuously execute
  35584. */
  35585. runRenderLoop(renderFunction: () => void): void;
  35586. /**
  35587. * Clear the current render buffer or the current render target (if any is set up)
  35588. * @param color defines the color to use
  35589. * @param backBuffer defines if the back buffer must be cleared
  35590. * @param depth defines if the depth buffer must be cleared
  35591. * @param stencil defines if the stencil buffer must be cleared
  35592. */
  35593. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35594. private _viewportCached;
  35595. /** @hidden */
  35596. _viewport(x: number, y: number, width: number, height: number): void;
  35597. /**
  35598. * Set the WebGL's viewport
  35599. * @param viewport defines the viewport element to be used
  35600. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35601. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35602. */
  35603. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35604. /**
  35605. * Begin a new frame
  35606. */
  35607. beginFrame(): void;
  35608. /**
  35609. * Enf the current frame
  35610. */
  35611. endFrame(): void;
  35612. /**
  35613. * Resize the view according to the canvas' size
  35614. */
  35615. resize(): void;
  35616. /**
  35617. * Force a specific size of the canvas
  35618. * @param width defines the new canvas' width
  35619. * @param height defines the new canvas' height
  35620. * @returns true if the size was changed
  35621. */
  35622. setSize(width: number, height: number): boolean;
  35623. /**
  35624. * Binds the frame buffer to the specified texture.
  35625. * @param texture The texture to render to or null for the default canvas
  35626. * @param faceIndex The face of the texture to render to in case of cube texture
  35627. * @param requiredWidth The width of the target to render to
  35628. * @param requiredHeight The height of the target to render to
  35629. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35630. * @param lodLevel defines the lod level to bind to the frame buffer
  35631. * @param layer defines the 2d array index to bind to frame buffer to
  35632. */
  35633. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35634. /** @hidden */
  35635. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35636. /**
  35637. * Unbind the current render target texture from the webGL context
  35638. * @param texture defines the render target texture to unbind
  35639. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35640. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35641. */
  35642. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35643. /**
  35644. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35645. */
  35646. flushFramebuffer(): void;
  35647. /**
  35648. * Unbind the current render target and bind the default framebuffer
  35649. */
  35650. restoreDefaultFramebuffer(): void;
  35651. /** @hidden */
  35652. protected _resetVertexBufferBinding(): void;
  35653. /**
  35654. * Creates a vertex buffer
  35655. * @param data the data for the vertex buffer
  35656. * @returns the new WebGL static buffer
  35657. */
  35658. createVertexBuffer(data: DataArray): DataBuffer;
  35659. private _createVertexBuffer;
  35660. /**
  35661. * Creates a dynamic vertex buffer
  35662. * @param data the data for the dynamic vertex buffer
  35663. * @returns the new WebGL dynamic buffer
  35664. */
  35665. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35666. protected _resetIndexBufferBinding(): void;
  35667. /**
  35668. * Creates a new index buffer
  35669. * @param indices defines the content of the index buffer
  35670. * @param updatable defines if the index buffer must be updatable
  35671. * @returns a new webGL buffer
  35672. */
  35673. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35674. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35675. /**
  35676. * Bind a webGL buffer to the webGL context
  35677. * @param buffer defines the buffer to bind
  35678. */
  35679. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35680. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35681. private bindBuffer;
  35682. /**
  35683. * update the bound buffer with the given data
  35684. * @param data defines the data to update
  35685. */
  35686. updateArrayBuffer(data: Float32Array): void;
  35687. private _vertexAttribPointer;
  35688. /** @hidden */
  35689. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35690. private _bindVertexBuffersAttributes;
  35691. /**
  35692. * Records a vertex array object
  35693. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35694. * @param vertexBuffers defines the list of vertex buffers to store
  35695. * @param indexBuffer defines the index buffer to store
  35696. * @param effect defines the effect to store
  35697. * @returns the new vertex array object
  35698. */
  35699. recordVertexArrayObject(vertexBuffers: {
  35700. [key: string]: VertexBuffer;
  35701. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35702. /**
  35703. * Bind a specific vertex array object
  35704. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35705. * @param vertexArrayObject defines the vertex array object to bind
  35706. * @param indexBuffer defines the index buffer to bind
  35707. */
  35708. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35709. /**
  35710. * Bind webGl buffers directly to the webGL context
  35711. * @param vertexBuffer defines the vertex buffer to bind
  35712. * @param indexBuffer defines the index buffer to bind
  35713. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35714. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35715. * @param effect defines the effect associated with the vertex buffer
  35716. */
  35717. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35718. private _unbindVertexArrayObject;
  35719. /**
  35720. * Bind a list of vertex buffers to the webGL context
  35721. * @param vertexBuffers defines the list of vertex buffers to bind
  35722. * @param indexBuffer defines the index buffer to bind
  35723. * @param effect defines the effect associated with the vertex buffers
  35724. */
  35725. bindBuffers(vertexBuffers: {
  35726. [key: string]: Nullable<VertexBuffer>;
  35727. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35728. /**
  35729. * Unbind all instance attributes
  35730. */
  35731. unbindInstanceAttributes(): void;
  35732. /**
  35733. * Release and free the memory of a vertex array object
  35734. * @param vao defines the vertex array object to delete
  35735. */
  35736. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35737. /** @hidden */
  35738. _releaseBuffer(buffer: DataBuffer): boolean;
  35739. protected _deleteBuffer(buffer: DataBuffer): void;
  35740. /**
  35741. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35742. * @param instancesBuffer defines the webGL buffer to update and bind
  35743. * @param data defines the data to store in the buffer
  35744. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35745. */
  35746. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35747. /**
  35748. * Bind the content of a webGL buffer used with instantiation
  35749. * @param instancesBuffer defines the webGL buffer to bind
  35750. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35751. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35752. */
  35753. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35754. /**
  35755. * Disable the instance attribute corresponding to the name in parameter
  35756. * @param name defines the name of the attribute to disable
  35757. */
  35758. disableInstanceAttributeByName(name: string): void;
  35759. /**
  35760. * Disable the instance attribute corresponding to the location in parameter
  35761. * @param attributeLocation defines the attribute location of the attribute to disable
  35762. */
  35763. disableInstanceAttribute(attributeLocation: number): void;
  35764. /**
  35765. * Disable the attribute corresponding to the location in parameter
  35766. * @param attributeLocation defines the attribute location of the attribute to disable
  35767. */
  35768. disableAttributeByIndex(attributeLocation: number): void;
  35769. /**
  35770. * Send a draw order
  35771. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35772. * @param indexStart defines the starting index
  35773. * @param indexCount defines the number of index to draw
  35774. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35775. */
  35776. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35777. /**
  35778. * Draw a list of points
  35779. * @param verticesStart defines the index of first vertex to draw
  35780. * @param verticesCount defines the count of vertices to draw
  35781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35782. */
  35783. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35784. /**
  35785. * Draw a list of unindexed primitives
  35786. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35787. * @param verticesStart defines the index of first vertex to draw
  35788. * @param verticesCount defines the count of vertices to draw
  35789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35790. */
  35791. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35792. /**
  35793. * Draw a list of indexed primitives
  35794. * @param fillMode defines the primitive to use
  35795. * @param indexStart defines the starting index
  35796. * @param indexCount defines the number of index to draw
  35797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35798. */
  35799. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35800. /**
  35801. * Draw a list of unindexed primitives
  35802. * @param fillMode defines the primitive to use
  35803. * @param verticesStart defines the index of first vertex to draw
  35804. * @param verticesCount defines the count of vertices to draw
  35805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35806. */
  35807. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35808. private _drawMode;
  35809. /** @hidden */
  35810. protected _reportDrawCall(): void;
  35811. /** @hidden */
  35812. _releaseEffect(effect: Effect): void;
  35813. /** @hidden */
  35814. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35815. /**
  35816. * Create a new effect (used to store vertex/fragment shaders)
  35817. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35818. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35819. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35820. * @param samplers defines an array of string used to represent textures
  35821. * @param defines defines the string containing the defines to use to compile the shaders
  35822. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35823. * @param onCompiled defines a function to call when the effect creation is successful
  35824. * @param onError defines a function to call when the effect creation has failed
  35825. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35826. * @returns the new Effect
  35827. */
  35828. 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;
  35829. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35830. private _compileShader;
  35831. private _compileRawShader;
  35832. /** @hidden */
  35833. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35834. /**
  35835. * Directly creates a webGL program
  35836. * @param pipelineContext defines the pipeline context to attach to
  35837. * @param vertexCode defines the vertex shader code to use
  35838. * @param fragmentCode defines the fragment shader code to use
  35839. * @param context defines the webGL context to use (if not set, the current one will be used)
  35840. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35841. * @returns the new webGL program
  35842. */
  35843. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35844. /**
  35845. * Creates a webGL program
  35846. * @param pipelineContext defines the pipeline context to attach to
  35847. * @param vertexCode defines the vertex shader code to use
  35848. * @param fragmentCode defines the fragment shader code to use
  35849. * @param defines defines the string containing the defines to use to compile the shaders
  35850. * @param context defines the webGL context to use (if not set, the current one will be used)
  35851. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35852. * @returns the new webGL program
  35853. */
  35854. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35855. /**
  35856. * Creates a new pipeline context
  35857. * @returns the new pipeline
  35858. */
  35859. createPipelineContext(): IPipelineContext;
  35860. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35861. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35862. /** @hidden */
  35863. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35864. /** @hidden */
  35865. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35866. /** @hidden */
  35867. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35868. /**
  35869. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35870. * @param pipelineContext defines the pipeline context to use
  35871. * @param uniformsNames defines the list of uniform names
  35872. * @returns an array of webGL uniform locations
  35873. */
  35874. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35875. /**
  35876. * Gets the lsit of active attributes for a given webGL program
  35877. * @param pipelineContext defines the pipeline context to use
  35878. * @param attributesNames defines the list of attribute names to get
  35879. * @returns an array of indices indicating the offset of each attribute
  35880. */
  35881. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35882. /**
  35883. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35884. * @param effect defines the effect to activate
  35885. */
  35886. enableEffect(effect: Nullable<Effect>): void;
  35887. /**
  35888. * Set the value of an uniform to a number (int)
  35889. * @param uniform defines the webGL uniform location where to store the value
  35890. * @param value defines the int number to store
  35891. */
  35892. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35893. /**
  35894. * Set the value of an uniform to an array of int32
  35895. * @param uniform defines the webGL uniform location where to store the value
  35896. * @param array defines the array of int32 to store
  35897. */
  35898. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35899. /**
  35900. * Set the value of an uniform to an array of int32 (stored as vec2)
  35901. * @param uniform defines the webGL uniform location where to store the value
  35902. * @param array defines the array of int32 to store
  35903. */
  35904. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35905. /**
  35906. * Set the value of an uniform to an array of int32 (stored as vec3)
  35907. * @param uniform defines the webGL uniform location where to store the value
  35908. * @param array defines the array of int32 to store
  35909. */
  35910. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35911. /**
  35912. * Set the value of an uniform to an array of int32 (stored as vec4)
  35913. * @param uniform defines the webGL uniform location where to store the value
  35914. * @param array defines the array of int32 to store
  35915. */
  35916. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35917. /**
  35918. * Set the value of an uniform to an array of number
  35919. * @param uniform defines the webGL uniform location where to store the value
  35920. * @param array defines the array of number to store
  35921. */
  35922. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35923. /**
  35924. * Set the value of an uniform to an array of number (stored as vec2)
  35925. * @param uniform defines the webGL uniform location where to store the value
  35926. * @param array defines the array of number to store
  35927. */
  35928. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35929. /**
  35930. * Set the value of an uniform to an array of number (stored as vec3)
  35931. * @param uniform defines the webGL uniform location where to store the value
  35932. * @param array defines the array of number to store
  35933. */
  35934. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35935. /**
  35936. * Set the value of an uniform to an array of number (stored as vec4)
  35937. * @param uniform defines the webGL uniform location where to store the value
  35938. * @param array defines the array of number to store
  35939. */
  35940. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35941. /**
  35942. * Set the value of an uniform to an array of float32 (stored as matrices)
  35943. * @param uniform defines the webGL uniform location where to store the value
  35944. * @param matrices defines the array of float32 to store
  35945. */
  35946. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35947. /**
  35948. * Set the value of an uniform to a matrix (3x3)
  35949. * @param uniform defines the webGL uniform location where to store the value
  35950. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35951. */
  35952. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35953. /**
  35954. * Set the value of an uniform to a matrix (2x2)
  35955. * @param uniform defines the webGL uniform location where to store the value
  35956. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35957. */
  35958. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35959. /**
  35960. * Set the value of an uniform to a number (float)
  35961. * @param uniform defines the webGL uniform location where to store the value
  35962. * @param value defines the float number to store
  35963. */
  35964. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35965. /**
  35966. * Set the value of an uniform to a vec2
  35967. * @param uniform defines the webGL uniform location where to store the value
  35968. * @param x defines the 1st component of the value
  35969. * @param y defines the 2nd component of the value
  35970. */
  35971. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35972. /**
  35973. * Set the value of an uniform to a vec3
  35974. * @param uniform defines the webGL uniform location where to store the value
  35975. * @param x defines the 1st component of the value
  35976. * @param y defines the 2nd component of the value
  35977. * @param z defines the 3rd component of the value
  35978. */
  35979. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35980. /**
  35981. * Set the value of an uniform to a vec4
  35982. * @param uniform defines the webGL uniform location where to store the value
  35983. * @param x defines the 1st component of the value
  35984. * @param y defines the 2nd component of the value
  35985. * @param z defines the 3rd component of the value
  35986. * @param w defines the 4th component of the value
  35987. */
  35988. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35989. /**
  35990. * Apply all cached states (depth, culling, stencil and alpha)
  35991. */
  35992. applyStates(): void;
  35993. /**
  35994. * Enable or disable color writing
  35995. * @param enable defines the state to set
  35996. */
  35997. setColorWrite(enable: boolean): void;
  35998. /**
  35999. * Gets a boolean indicating if color writing is enabled
  36000. * @returns the current color writing state
  36001. */
  36002. getColorWrite(): boolean;
  36003. /**
  36004. * Gets the depth culling state manager
  36005. */
  36006. get depthCullingState(): DepthCullingState;
  36007. /**
  36008. * Gets the alpha state manager
  36009. */
  36010. get alphaState(): AlphaState;
  36011. /**
  36012. * Gets the stencil state manager
  36013. */
  36014. get stencilState(): StencilState;
  36015. /**
  36016. * Clears the list of texture accessible through engine.
  36017. * This can help preventing texture load conflict due to name collision.
  36018. */
  36019. clearInternalTexturesCache(): void;
  36020. /**
  36021. * Force the entire cache to be cleared
  36022. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36023. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36024. */
  36025. wipeCaches(bruteForce?: boolean): void;
  36026. /** @hidden */
  36027. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36028. min: number;
  36029. mag: number;
  36030. };
  36031. /** @hidden */
  36032. _createTexture(): WebGLTexture;
  36033. /**
  36034. * Usually called from Texture.ts.
  36035. * Passed information to create a WebGLTexture
  36036. * @param url defines a value which contains one of the following:
  36037. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36038. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36039. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36040. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36041. * @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)
  36042. * @param scene needed for loading to the correct scene
  36043. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36044. * @param onLoad optional callback to be called upon successful completion
  36045. * @param onError optional callback to be called upon failure
  36046. * @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
  36047. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36048. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36049. * @param forcedExtension defines the extension to use to pick the right loader
  36050. * @param mimeType defines an optional mime type
  36051. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36052. */
  36053. 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;
  36054. /**
  36055. * Loads an image as an HTMLImageElement.
  36056. * @param input url string, ArrayBuffer, or Blob to load
  36057. * @param onLoad callback called when the image successfully loads
  36058. * @param onError callback called when the image fails to load
  36059. * @param offlineProvider offline provider for caching
  36060. * @param mimeType optional mime type
  36061. * @returns the HTMLImageElement of the loaded image
  36062. * @hidden
  36063. */
  36064. 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>;
  36065. /**
  36066. * @hidden
  36067. */
  36068. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36069. private _unpackFlipYCached;
  36070. /**
  36071. * In case you are sharing the context with other applications, it might
  36072. * be interested to not cache the unpack flip y state to ensure a consistent
  36073. * value would be set.
  36074. */
  36075. enableUnpackFlipYCached: boolean;
  36076. /** @hidden */
  36077. _unpackFlipY(value: boolean): void;
  36078. /** @hidden */
  36079. _getUnpackAlignement(): number;
  36080. private _getTextureTarget;
  36081. /**
  36082. * Update the sampling mode of a given texture
  36083. * @param samplingMode defines the required sampling mode
  36084. * @param texture defines the texture to update
  36085. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36086. */
  36087. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36088. /**
  36089. * Update the sampling mode of a given texture
  36090. * @param texture defines the texture to update
  36091. * @param wrapU defines the texture wrap mode of the u coordinates
  36092. * @param wrapV defines the texture wrap mode of the v coordinates
  36093. * @param wrapR defines the texture wrap mode of the r coordinates
  36094. */
  36095. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36096. /** @hidden */
  36097. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36098. width: number;
  36099. height: number;
  36100. layers?: number;
  36101. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36102. /** @hidden */
  36103. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36104. /** @hidden */
  36105. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36106. /**
  36107. * Update a portion of an internal texture
  36108. * @param texture defines the texture to update
  36109. * @param imageData defines the data to store into the texture
  36110. * @param xOffset defines the x coordinates of the update rectangle
  36111. * @param yOffset defines the y coordinates of the update rectangle
  36112. * @param width defines the width of the update rectangle
  36113. * @param height defines the height of the update rectangle
  36114. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36115. * @param lod defines the lod level to update (0 by default)
  36116. */
  36117. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36118. /** @hidden */
  36119. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36120. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36121. private _prepareWebGLTexture;
  36122. /** @hidden */
  36123. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36124. private _getDepthStencilBuffer;
  36125. /** @hidden */
  36126. _releaseFramebufferObjects(texture: InternalTexture): void;
  36127. /** @hidden */
  36128. _releaseTexture(texture: InternalTexture): void;
  36129. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36130. protected _setProgram(program: WebGLProgram): void;
  36131. protected _boundUniforms: {
  36132. [key: number]: WebGLUniformLocation;
  36133. };
  36134. /**
  36135. * Binds an effect to the webGL context
  36136. * @param effect defines the effect to bind
  36137. */
  36138. bindSamplers(effect: Effect): void;
  36139. private _activateCurrentTexture;
  36140. /** @hidden */
  36141. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36142. /** @hidden */
  36143. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36144. /**
  36145. * Unbind all textures from the webGL context
  36146. */
  36147. unbindAllTextures(): void;
  36148. /**
  36149. * Sets a texture to the according uniform.
  36150. * @param channel The texture channel
  36151. * @param uniform The uniform to set
  36152. * @param texture The texture to apply
  36153. */
  36154. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36155. private _bindSamplerUniformToChannel;
  36156. private _getTextureWrapMode;
  36157. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36158. /**
  36159. * Sets an array of texture to the webGL context
  36160. * @param channel defines the channel where the texture array must be set
  36161. * @param uniform defines the associated uniform location
  36162. * @param textures defines the array of textures to bind
  36163. */
  36164. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36165. /** @hidden */
  36166. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36167. private _setTextureParameterFloat;
  36168. private _setTextureParameterInteger;
  36169. /**
  36170. * Unbind all vertex attributes from the webGL context
  36171. */
  36172. unbindAllAttributes(): void;
  36173. /**
  36174. * 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
  36175. */
  36176. releaseEffects(): void;
  36177. /**
  36178. * Dispose and release all associated resources
  36179. */
  36180. dispose(): void;
  36181. /**
  36182. * Attach a new callback raised when context lost event is fired
  36183. * @param callback defines the callback to call
  36184. */
  36185. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36186. /**
  36187. * Attach a new callback raised when context restored event is fired
  36188. * @param callback defines the callback to call
  36189. */
  36190. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36191. /**
  36192. * Get the current error code of the webGL context
  36193. * @returns the error code
  36194. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36195. */
  36196. getError(): number;
  36197. private _canRenderToFloatFramebuffer;
  36198. private _canRenderToHalfFloatFramebuffer;
  36199. private _canRenderToFramebuffer;
  36200. /** @hidden */
  36201. _getWebGLTextureType(type: number): number;
  36202. /** @hidden */
  36203. _getInternalFormat(format: number): number;
  36204. /** @hidden */
  36205. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36206. /** @hidden */
  36207. _getRGBAMultiSampleBufferFormat(type: number): number;
  36208. /** @hidden */
  36209. _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;
  36210. /**
  36211. * Loads a file from a url
  36212. * @param url url to load
  36213. * @param onSuccess callback called when the file successfully loads
  36214. * @param onProgress callback called while file is loading (if the server supports this mode)
  36215. * @param offlineProvider defines the offline provider for caching
  36216. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36217. * @param onError callback called when the file fails to load
  36218. * @returns a file request object
  36219. * @hidden
  36220. */
  36221. 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;
  36222. /**
  36223. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36224. * @param x defines the x coordinate of the rectangle where pixels must be read
  36225. * @param y defines the y coordinate of the rectangle where pixels must be read
  36226. * @param width defines the width of the rectangle where pixels must be read
  36227. * @param height defines the height of the rectangle where pixels must be read
  36228. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36229. * @returns a Uint8Array containing RGBA colors
  36230. */
  36231. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36232. private static _isSupported;
  36233. /**
  36234. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36235. * @returns true if the engine can be created
  36236. * @ignorenaming
  36237. */
  36238. static isSupported(): boolean;
  36239. /**
  36240. * Find the next highest power of two.
  36241. * @param x Number to start search from.
  36242. * @return Next highest power of two.
  36243. */
  36244. static CeilingPOT(x: number): number;
  36245. /**
  36246. * Find the next lowest power of two.
  36247. * @param x Number to start search from.
  36248. * @return Next lowest power of two.
  36249. */
  36250. static FloorPOT(x: number): number;
  36251. /**
  36252. * Find the nearest power of two.
  36253. * @param x Number to start search from.
  36254. * @return Next nearest power of two.
  36255. */
  36256. static NearestPOT(x: number): number;
  36257. /**
  36258. * Get the closest exponent of two
  36259. * @param value defines the value to approximate
  36260. * @param max defines the maximum value to return
  36261. * @param mode defines how to define the closest value
  36262. * @returns closest exponent of two of the given value
  36263. */
  36264. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36265. /**
  36266. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36267. * @param func - the function to be called
  36268. * @param requester - the object that will request the next frame. Falls back to window.
  36269. * @returns frame number
  36270. */
  36271. static QueueNewFrame(func: () => void, requester?: any): number;
  36272. /**
  36273. * Gets host document
  36274. * @returns the host document object
  36275. */
  36276. getHostDocument(): Nullable<Document>;
  36277. }
  36278. }
  36279. declare module BABYLON {
  36280. /**
  36281. * Class representing spherical harmonics coefficients to the 3rd degree
  36282. */
  36283. export class SphericalHarmonics {
  36284. /**
  36285. * Defines whether or not the harmonics have been prescaled for rendering.
  36286. */
  36287. preScaled: boolean;
  36288. /**
  36289. * The l0,0 coefficients of the spherical harmonics
  36290. */
  36291. l00: Vector3;
  36292. /**
  36293. * The l1,-1 coefficients of the spherical harmonics
  36294. */
  36295. l1_1: Vector3;
  36296. /**
  36297. * The l1,0 coefficients of the spherical harmonics
  36298. */
  36299. l10: Vector3;
  36300. /**
  36301. * The l1,1 coefficients of the spherical harmonics
  36302. */
  36303. l11: Vector3;
  36304. /**
  36305. * The l2,-2 coefficients of the spherical harmonics
  36306. */
  36307. l2_2: Vector3;
  36308. /**
  36309. * The l2,-1 coefficients of the spherical harmonics
  36310. */
  36311. l2_1: Vector3;
  36312. /**
  36313. * The l2,0 coefficients of the spherical harmonics
  36314. */
  36315. l20: Vector3;
  36316. /**
  36317. * The l2,1 coefficients of the spherical harmonics
  36318. */
  36319. l21: Vector3;
  36320. /**
  36321. * The l2,2 coefficients of the spherical harmonics
  36322. */
  36323. l22: Vector3;
  36324. /**
  36325. * Adds a light to the spherical harmonics
  36326. * @param direction the direction of the light
  36327. * @param color the color of the light
  36328. * @param deltaSolidAngle the delta solid angle of the light
  36329. */
  36330. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36331. /**
  36332. * Scales the spherical harmonics by the given amount
  36333. * @param scale the amount to scale
  36334. */
  36335. scaleInPlace(scale: number): void;
  36336. /**
  36337. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36338. *
  36339. * ```
  36340. * E_lm = A_l * L_lm
  36341. * ```
  36342. *
  36343. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36344. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36345. * the scaling factors are given in equation 9.
  36346. */
  36347. convertIncidentRadianceToIrradiance(): void;
  36348. /**
  36349. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36350. *
  36351. * ```
  36352. * L = (1/pi) * E * rho
  36353. * ```
  36354. *
  36355. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36356. */
  36357. convertIrradianceToLambertianRadiance(): void;
  36358. /**
  36359. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36360. * required operations at run time.
  36361. *
  36362. * This is simply done by scaling back the SH with Ylm constants parameter.
  36363. * The trigonometric part being applied by the shader at run time.
  36364. */
  36365. preScaleForRendering(): void;
  36366. /**
  36367. * Constructs a spherical harmonics from an array.
  36368. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36369. * @returns the spherical harmonics
  36370. */
  36371. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36372. /**
  36373. * Gets the spherical harmonics from polynomial
  36374. * @param polynomial the spherical polynomial
  36375. * @returns the spherical harmonics
  36376. */
  36377. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36378. }
  36379. /**
  36380. * Class representing spherical polynomial coefficients to the 3rd degree
  36381. */
  36382. export class SphericalPolynomial {
  36383. private _harmonics;
  36384. /**
  36385. * The spherical harmonics used to create the polynomials.
  36386. */
  36387. get preScaledHarmonics(): SphericalHarmonics;
  36388. /**
  36389. * The x coefficients of the spherical polynomial
  36390. */
  36391. x: Vector3;
  36392. /**
  36393. * The y coefficients of the spherical polynomial
  36394. */
  36395. y: Vector3;
  36396. /**
  36397. * The z coefficients of the spherical polynomial
  36398. */
  36399. z: Vector3;
  36400. /**
  36401. * The xx coefficients of the spherical polynomial
  36402. */
  36403. xx: Vector3;
  36404. /**
  36405. * The yy coefficients of the spherical polynomial
  36406. */
  36407. yy: Vector3;
  36408. /**
  36409. * The zz coefficients of the spherical polynomial
  36410. */
  36411. zz: Vector3;
  36412. /**
  36413. * The xy coefficients of the spherical polynomial
  36414. */
  36415. xy: Vector3;
  36416. /**
  36417. * The yz coefficients of the spherical polynomial
  36418. */
  36419. yz: Vector3;
  36420. /**
  36421. * The zx coefficients of the spherical polynomial
  36422. */
  36423. zx: Vector3;
  36424. /**
  36425. * Adds an ambient color to the spherical polynomial
  36426. * @param color the color to add
  36427. */
  36428. addAmbient(color: Color3): void;
  36429. /**
  36430. * Scales the spherical polynomial by the given amount
  36431. * @param scale the amount to scale
  36432. */
  36433. scaleInPlace(scale: number): void;
  36434. /**
  36435. * Gets the spherical polynomial from harmonics
  36436. * @param harmonics the spherical harmonics
  36437. * @returns the spherical polynomial
  36438. */
  36439. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36440. /**
  36441. * Constructs a spherical polynomial from an array.
  36442. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36443. * @returns the spherical polynomial
  36444. */
  36445. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36446. }
  36447. }
  36448. declare module BABYLON {
  36449. /**
  36450. * Defines the source of the internal texture
  36451. */
  36452. export enum InternalTextureSource {
  36453. /**
  36454. * The source of the texture data is unknown
  36455. */
  36456. Unknown = 0,
  36457. /**
  36458. * Texture data comes from an URL
  36459. */
  36460. Url = 1,
  36461. /**
  36462. * Texture data is only used for temporary storage
  36463. */
  36464. Temp = 2,
  36465. /**
  36466. * Texture data comes from raw data (ArrayBuffer)
  36467. */
  36468. Raw = 3,
  36469. /**
  36470. * Texture content is dynamic (video or dynamic texture)
  36471. */
  36472. Dynamic = 4,
  36473. /**
  36474. * Texture content is generated by rendering to it
  36475. */
  36476. RenderTarget = 5,
  36477. /**
  36478. * Texture content is part of a multi render target process
  36479. */
  36480. MultiRenderTarget = 6,
  36481. /**
  36482. * Texture data comes from a cube data file
  36483. */
  36484. Cube = 7,
  36485. /**
  36486. * Texture data comes from a raw cube data
  36487. */
  36488. CubeRaw = 8,
  36489. /**
  36490. * Texture data come from a prefiltered cube data file
  36491. */
  36492. CubePrefiltered = 9,
  36493. /**
  36494. * Texture content is raw 3D data
  36495. */
  36496. Raw3D = 10,
  36497. /**
  36498. * Texture content is raw 2D array data
  36499. */
  36500. Raw2DArray = 11,
  36501. /**
  36502. * Texture content is a depth texture
  36503. */
  36504. Depth = 12,
  36505. /**
  36506. * Texture data comes from a raw cube data encoded with RGBD
  36507. */
  36508. CubeRawRGBD = 13
  36509. }
  36510. /**
  36511. * Class used to store data associated with WebGL texture data for the engine
  36512. * This class should not be used directly
  36513. */
  36514. export class InternalTexture {
  36515. /** @hidden */
  36516. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36517. /**
  36518. * Defines if the texture is ready
  36519. */
  36520. isReady: boolean;
  36521. /**
  36522. * Defines if the texture is a cube texture
  36523. */
  36524. isCube: boolean;
  36525. /**
  36526. * Defines if the texture contains 3D data
  36527. */
  36528. is3D: boolean;
  36529. /**
  36530. * Defines if the texture contains 2D array data
  36531. */
  36532. is2DArray: boolean;
  36533. /**
  36534. * Defines if the texture contains multiview data
  36535. */
  36536. isMultiview: boolean;
  36537. /**
  36538. * Gets the URL used to load this texture
  36539. */
  36540. url: string;
  36541. /**
  36542. * Gets the sampling mode of the texture
  36543. */
  36544. samplingMode: number;
  36545. /**
  36546. * Gets a boolean indicating if the texture needs mipmaps generation
  36547. */
  36548. generateMipMaps: boolean;
  36549. /**
  36550. * Gets the number of samples used by the texture (WebGL2+ only)
  36551. */
  36552. samples: number;
  36553. /**
  36554. * Gets the type of the texture (int, float...)
  36555. */
  36556. type: number;
  36557. /**
  36558. * Gets the format of the texture (RGB, RGBA...)
  36559. */
  36560. format: number;
  36561. /**
  36562. * Observable called when the texture is loaded
  36563. */
  36564. onLoadedObservable: Observable<InternalTexture>;
  36565. /**
  36566. * Gets the width of the texture
  36567. */
  36568. width: number;
  36569. /**
  36570. * Gets the height of the texture
  36571. */
  36572. height: number;
  36573. /**
  36574. * Gets the depth of the texture
  36575. */
  36576. depth: number;
  36577. /**
  36578. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36579. */
  36580. baseWidth: number;
  36581. /**
  36582. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36583. */
  36584. baseHeight: number;
  36585. /**
  36586. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36587. */
  36588. baseDepth: number;
  36589. /**
  36590. * Gets a boolean indicating if the texture is inverted on Y axis
  36591. */
  36592. invertY: boolean;
  36593. /** @hidden */
  36594. _invertVScale: boolean;
  36595. /** @hidden */
  36596. _associatedChannel: number;
  36597. /** @hidden */
  36598. _source: InternalTextureSource;
  36599. /** @hidden */
  36600. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36601. /** @hidden */
  36602. _bufferView: Nullable<ArrayBufferView>;
  36603. /** @hidden */
  36604. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36605. /** @hidden */
  36606. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36607. /** @hidden */
  36608. _size: number;
  36609. /** @hidden */
  36610. _extension: string;
  36611. /** @hidden */
  36612. _files: Nullable<string[]>;
  36613. /** @hidden */
  36614. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36615. /** @hidden */
  36616. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36617. /** @hidden */
  36618. _framebuffer: Nullable<WebGLFramebuffer>;
  36619. /** @hidden */
  36620. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36621. /** @hidden */
  36622. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36623. /** @hidden */
  36624. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36625. /** @hidden */
  36626. _attachments: Nullable<number[]>;
  36627. /** @hidden */
  36628. _textureArray: Nullable<InternalTexture[]>;
  36629. /** @hidden */
  36630. _cachedCoordinatesMode: Nullable<number>;
  36631. /** @hidden */
  36632. _cachedWrapU: Nullable<number>;
  36633. /** @hidden */
  36634. _cachedWrapV: Nullable<number>;
  36635. /** @hidden */
  36636. _cachedWrapR: Nullable<number>;
  36637. /** @hidden */
  36638. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36639. /** @hidden */
  36640. _isDisabled: boolean;
  36641. /** @hidden */
  36642. _compression: Nullable<string>;
  36643. /** @hidden */
  36644. _generateStencilBuffer: boolean;
  36645. /** @hidden */
  36646. _generateDepthBuffer: boolean;
  36647. /** @hidden */
  36648. _comparisonFunction: number;
  36649. /** @hidden */
  36650. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36651. /** @hidden */
  36652. _lodGenerationScale: number;
  36653. /** @hidden */
  36654. _lodGenerationOffset: number;
  36655. /** @hidden */
  36656. _depthStencilTexture: Nullable<InternalTexture>;
  36657. /** @hidden */
  36658. _colorTextureArray: Nullable<WebGLTexture>;
  36659. /** @hidden */
  36660. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36661. /** @hidden */
  36662. _lodTextureHigh: Nullable<BaseTexture>;
  36663. /** @hidden */
  36664. _lodTextureMid: Nullable<BaseTexture>;
  36665. /** @hidden */
  36666. _lodTextureLow: Nullable<BaseTexture>;
  36667. /** @hidden */
  36668. _isRGBD: boolean;
  36669. /** @hidden */
  36670. _linearSpecularLOD: boolean;
  36671. /** @hidden */
  36672. _irradianceTexture: Nullable<BaseTexture>;
  36673. /** @hidden */
  36674. _webGLTexture: Nullable<WebGLTexture>;
  36675. /** @hidden */
  36676. _references: number;
  36677. private _engine;
  36678. /**
  36679. * Gets the Engine the texture belongs to.
  36680. * @returns The babylon engine
  36681. */
  36682. getEngine(): ThinEngine;
  36683. /**
  36684. * Gets the data source type of the texture
  36685. */
  36686. get source(): InternalTextureSource;
  36687. /**
  36688. * Creates a new InternalTexture
  36689. * @param engine defines the engine to use
  36690. * @param source defines the type of data that will be used
  36691. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36692. */
  36693. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36694. /**
  36695. * Increments the number of references (ie. the number of Texture that point to it)
  36696. */
  36697. incrementReferences(): void;
  36698. /**
  36699. * Change the size of the texture (not the size of the content)
  36700. * @param width defines the new width
  36701. * @param height defines the new height
  36702. * @param depth defines the new depth (1 by default)
  36703. */
  36704. updateSize(width: int, height: int, depth?: int): void;
  36705. /** @hidden */
  36706. _rebuild(): void;
  36707. /** @hidden */
  36708. _swapAndDie(target: InternalTexture): void;
  36709. /**
  36710. * Dispose the current allocated resources
  36711. */
  36712. dispose(): void;
  36713. }
  36714. }
  36715. declare module BABYLON {
  36716. /**
  36717. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36719. */
  36720. export class Analyser {
  36721. /**
  36722. * Gets or sets the smoothing
  36723. * @ignorenaming
  36724. */
  36725. SMOOTHING: number;
  36726. /**
  36727. * Gets or sets the FFT table size
  36728. * @ignorenaming
  36729. */
  36730. FFT_SIZE: number;
  36731. /**
  36732. * Gets or sets the bar graph amplitude
  36733. * @ignorenaming
  36734. */
  36735. BARGRAPHAMPLITUDE: number;
  36736. /**
  36737. * Gets or sets the position of the debug canvas
  36738. * @ignorenaming
  36739. */
  36740. DEBUGCANVASPOS: {
  36741. x: number;
  36742. y: number;
  36743. };
  36744. /**
  36745. * Gets or sets the debug canvas size
  36746. * @ignorenaming
  36747. */
  36748. DEBUGCANVASSIZE: {
  36749. width: number;
  36750. height: number;
  36751. };
  36752. private _byteFreqs;
  36753. private _byteTime;
  36754. private _floatFreqs;
  36755. private _webAudioAnalyser;
  36756. private _debugCanvas;
  36757. private _debugCanvasContext;
  36758. private _scene;
  36759. private _registerFunc;
  36760. private _audioEngine;
  36761. /**
  36762. * Creates a new analyser
  36763. * @param scene defines hosting scene
  36764. */
  36765. constructor(scene: Scene);
  36766. /**
  36767. * Get the number of data values you will have to play with for the visualization
  36768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36769. * @returns a number
  36770. */
  36771. getFrequencyBinCount(): number;
  36772. /**
  36773. * Gets the current frequency data as a byte array
  36774. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36775. * @returns a Uint8Array
  36776. */
  36777. getByteFrequencyData(): Uint8Array;
  36778. /**
  36779. * Gets the current waveform as a byte array
  36780. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36781. * @returns a Uint8Array
  36782. */
  36783. getByteTimeDomainData(): Uint8Array;
  36784. /**
  36785. * Gets the current frequency data as a float array
  36786. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36787. * @returns a Float32Array
  36788. */
  36789. getFloatFrequencyData(): Float32Array;
  36790. /**
  36791. * Renders the debug canvas
  36792. */
  36793. drawDebugCanvas(): void;
  36794. /**
  36795. * Stops rendering the debug canvas and removes it
  36796. */
  36797. stopDebugCanvas(): void;
  36798. /**
  36799. * Connects two audio nodes
  36800. * @param inputAudioNode defines first node to connect
  36801. * @param outputAudioNode defines second node to connect
  36802. */
  36803. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36804. /**
  36805. * Releases all associated resources
  36806. */
  36807. dispose(): void;
  36808. }
  36809. }
  36810. declare module BABYLON {
  36811. /**
  36812. * This represents an audio engine and it is responsible
  36813. * to play, synchronize and analyse sounds throughout the application.
  36814. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36815. */
  36816. export interface IAudioEngine extends IDisposable {
  36817. /**
  36818. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36819. */
  36820. readonly canUseWebAudio: boolean;
  36821. /**
  36822. * Gets the current AudioContext if available.
  36823. */
  36824. readonly audioContext: Nullable<AudioContext>;
  36825. /**
  36826. * The master gain node defines the global audio volume of your audio engine.
  36827. */
  36828. readonly masterGain: GainNode;
  36829. /**
  36830. * Gets whether or not mp3 are supported by your browser.
  36831. */
  36832. readonly isMP3supported: boolean;
  36833. /**
  36834. * Gets whether or not ogg are supported by your browser.
  36835. */
  36836. readonly isOGGsupported: boolean;
  36837. /**
  36838. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36839. * @ignoreNaming
  36840. */
  36841. WarnedWebAudioUnsupported: boolean;
  36842. /**
  36843. * Defines if the audio engine relies on a custom unlocked button.
  36844. * In this case, the embedded button will not be displayed.
  36845. */
  36846. useCustomUnlockedButton: boolean;
  36847. /**
  36848. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36849. */
  36850. readonly unlocked: boolean;
  36851. /**
  36852. * Event raised when audio has been unlocked on the browser.
  36853. */
  36854. onAudioUnlockedObservable: Observable<AudioEngine>;
  36855. /**
  36856. * Event raised when audio has been locked on the browser.
  36857. */
  36858. onAudioLockedObservable: Observable<AudioEngine>;
  36859. /**
  36860. * Flags the audio engine in Locked state.
  36861. * This happens due to new browser policies preventing audio to autoplay.
  36862. */
  36863. lock(): void;
  36864. /**
  36865. * Unlocks the audio engine once a user action has been done on the dom.
  36866. * This is helpful to resume play once browser policies have been satisfied.
  36867. */
  36868. unlock(): void;
  36869. /**
  36870. * Gets the global volume sets on the master gain.
  36871. * @returns the global volume if set or -1 otherwise
  36872. */
  36873. getGlobalVolume(): number;
  36874. /**
  36875. * Sets the global volume of your experience (sets on the master gain).
  36876. * @param newVolume Defines the new global volume of the application
  36877. */
  36878. setGlobalVolume(newVolume: number): void;
  36879. /**
  36880. * Connect the audio engine to an audio analyser allowing some amazing
  36881. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36882. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36883. * @param analyser The analyser to connect to the engine
  36884. */
  36885. connectToAnalyser(analyser: Analyser): void;
  36886. }
  36887. /**
  36888. * This represents the default audio engine used in babylon.
  36889. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36890. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36891. */
  36892. export class AudioEngine implements IAudioEngine {
  36893. private _audioContext;
  36894. private _audioContextInitialized;
  36895. private _muteButton;
  36896. private _hostElement;
  36897. /**
  36898. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36899. */
  36900. canUseWebAudio: boolean;
  36901. /**
  36902. * The master gain node defines the global audio volume of your audio engine.
  36903. */
  36904. masterGain: GainNode;
  36905. /**
  36906. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36907. * @ignoreNaming
  36908. */
  36909. WarnedWebAudioUnsupported: boolean;
  36910. /**
  36911. * Gets whether or not mp3 are supported by your browser.
  36912. */
  36913. isMP3supported: boolean;
  36914. /**
  36915. * Gets whether or not ogg are supported by your browser.
  36916. */
  36917. isOGGsupported: boolean;
  36918. /**
  36919. * Gets whether audio has been unlocked on the device.
  36920. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36921. * a user interaction has happened.
  36922. */
  36923. unlocked: boolean;
  36924. /**
  36925. * Defines if the audio engine relies on a custom unlocked button.
  36926. * In this case, the embedded button will not be displayed.
  36927. */
  36928. useCustomUnlockedButton: boolean;
  36929. /**
  36930. * Event raised when audio has been unlocked on the browser.
  36931. */
  36932. onAudioUnlockedObservable: Observable<AudioEngine>;
  36933. /**
  36934. * Event raised when audio has been locked on the browser.
  36935. */
  36936. onAudioLockedObservable: Observable<AudioEngine>;
  36937. /**
  36938. * Gets the current AudioContext if available.
  36939. */
  36940. get audioContext(): Nullable<AudioContext>;
  36941. private _connectedAnalyser;
  36942. /**
  36943. * Instantiates a new audio engine.
  36944. *
  36945. * There should be only one per page as some browsers restrict the number
  36946. * of audio contexts you can create.
  36947. * @param hostElement defines the host element where to display the mute icon if necessary
  36948. */
  36949. constructor(hostElement?: Nullable<HTMLElement>);
  36950. /**
  36951. * Flags the audio engine in Locked state.
  36952. * This happens due to new browser policies preventing audio to autoplay.
  36953. */
  36954. lock(): void;
  36955. /**
  36956. * Unlocks the audio engine once a user action has been done on the dom.
  36957. * This is helpful to resume play once browser policies have been satisfied.
  36958. */
  36959. unlock(): void;
  36960. private _resumeAudioContext;
  36961. private _initializeAudioContext;
  36962. private _tryToRun;
  36963. private _triggerRunningState;
  36964. private _triggerSuspendedState;
  36965. private _displayMuteButton;
  36966. private _moveButtonToTopLeft;
  36967. private _onResize;
  36968. private _hideMuteButton;
  36969. /**
  36970. * Destroy and release the resources associated with the audio ccontext.
  36971. */
  36972. dispose(): void;
  36973. /**
  36974. * Gets the global volume sets on the master gain.
  36975. * @returns the global volume if set or -1 otherwise
  36976. */
  36977. getGlobalVolume(): number;
  36978. /**
  36979. * Sets the global volume of your experience (sets on the master gain).
  36980. * @param newVolume Defines the new global volume of the application
  36981. */
  36982. setGlobalVolume(newVolume: number): void;
  36983. /**
  36984. * Connect the audio engine to an audio analyser allowing some amazing
  36985. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36987. * @param analyser The analyser to connect to the engine
  36988. */
  36989. connectToAnalyser(analyser: Analyser): void;
  36990. }
  36991. }
  36992. declare module BABYLON {
  36993. /**
  36994. * Interface used to present a loading screen while loading a scene
  36995. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36996. */
  36997. export interface ILoadingScreen {
  36998. /**
  36999. * Function called to display the loading screen
  37000. */
  37001. displayLoadingUI: () => void;
  37002. /**
  37003. * Function called to hide the loading screen
  37004. */
  37005. hideLoadingUI: () => void;
  37006. /**
  37007. * Gets or sets the color to use for the background
  37008. */
  37009. loadingUIBackgroundColor: string;
  37010. /**
  37011. * Gets or sets the text to display while loading
  37012. */
  37013. loadingUIText: string;
  37014. }
  37015. /**
  37016. * Class used for the default loading screen
  37017. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37018. */
  37019. export class DefaultLoadingScreen implements ILoadingScreen {
  37020. private _renderingCanvas;
  37021. private _loadingText;
  37022. private _loadingDivBackgroundColor;
  37023. private _loadingDiv;
  37024. private _loadingTextDiv;
  37025. /** Gets or sets the logo url to use for the default loading screen */
  37026. static DefaultLogoUrl: string;
  37027. /** Gets or sets the spinner url to use for the default loading screen */
  37028. static DefaultSpinnerUrl: string;
  37029. /**
  37030. * Creates a new default loading screen
  37031. * @param _renderingCanvas defines the canvas used to render the scene
  37032. * @param _loadingText defines the default text to display
  37033. * @param _loadingDivBackgroundColor defines the default background color
  37034. */
  37035. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37036. /**
  37037. * Function called to display the loading screen
  37038. */
  37039. displayLoadingUI(): void;
  37040. /**
  37041. * Function called to hide the loading screen
  37042. */
  37043. hideLoadingUI(): void;
  37044. /**
  37045. * Gets or sets the text to display while loading
  37046. */
  37047. set loadingUIText(text: string);
  37048. get loadingUIText(): string;
  37049. /**
  37050. * Gets or sets the color to use for the background
  37051. */
  37052. get loadingUIBackgroundColor(): string;
  37053. set loadingUIBackgroundColor(color: string);
  37054. private _resizeLoadingUI;
  37055. }
  37056. }
  37057. declare module BABYLON {
  37058. /**
  37059. * Interface for any object that can request an animation frame
  37060. */
  37061. export interface ICustomAnimationFrameRequester {
  37062. /**
  37063. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37064. */
  37065. renderFunction?: Function;
  37066. /**
  37067. * Called to request the next frame to render to
  37068. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37069. */
  37070. requestAnimationFrame: Function;
  37071. /**
  37072. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37073. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37074. */
  37075. requestID?: number;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /**
  37080. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37081. */
  37082. export class PerformanceMonitor {
  37083. private _enabled;
  37084. private _rollingFrameTime;
  37085. private _lastFrameTimeMs;
  37086. /**
  37087. * constructor
  37088. * @param frameSampleSize The number of samples required to saturate the sliding window
  37089. */
  37090. constructor(frameSampleSize?: number);
  37091. /**
  37092. * Samples current frame
  37093. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37094. */
  37095. sampleFrame(timeMs?: number): void;
  37096. /**
  37097. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37098. */
  37099. get averageFrameTime(): number;
  37100. /**
  37101. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37102. */
  37103. get averageFrameTimeVariance(): number;
  37104. /**
  37105. * Returns the frame time of the most recent frame
  37106. */
  37107. get instantaneousFrameTime(): number;
  37108. /**
  37109. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37110. */
  37111. get averageFPS(): number;
  37112. /**
  37113. * Returns the average framerate in frames per second using the most recent frame time
  37114. */
  37115. get instantaneousFPS(): number;
  37116. /**
  37117. * Returns true if enough samples have been taken to completely fill the sliding window
  37118. */
  37119. get isSaturated(): boolean;
  37120. /**
  37121. * Enables contributions to the sliding window sample set
  37122. */
  37123. enable(): void;
  37124. /**
  37125. * Disables contributions to the sliding window sample set
  37126. * Samples will not be interpolated over the disabled period
  37127. */
  37128. disable(): void;
  37129. /**
  37130. * Returns true if sampling is enabled
  37131. */
  37132. get isEnabled(): boolean;
  37133. /**
  37134. * Resets performance monitor
  37135. */
  37136. reset(): void;
  37137. }
  37138. /**
  37139. * RollingAverage
  37140. *
  37141. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37142. */
  37143. export class RollingAverage {
  37144. /**
  37145. * Current average
  37146. */
  37147. average: number;
  37148. /**
  37149. * Current variance
  37150. */
  37151. variance: number;
  37152. protected _samples: Array<number>;
  37153. protected _sampleCount: number;
  37154. protected _pos: number;
  37155. protected _m2: number;
  37156. /**
  37157. * constructor
  37158. * @param length The number of samples required to saturate the sliding window
  37159. */
  37160. constructor(length: number);
  37161. /**
  37162. * Adds a sample to the sample set
  37163. * @param v The sample value
  37164. */
  37165. add(v: number): void;
  37166. /**
  37167. * Returns previously added values or null if outside of history or outside the sliding window domain
  37168. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37169. * @return Value previously recorded with add() or null if outside of range
  37170. */
  37171. history(i: number): number;
  37172. /**
  37173. * Returns true if enough samples have been taken to completely fill the sliding window
  37174. * @return true if sample-set saturated
  37175. */
  37176. isSaturated(): boolean;
  37177. /**
  37178. * Resets the rolling average (equivalent to 0 samples taken so far)
  37179. */
  37180. reset(): void;
  37181. /**
  37182. * Wraps a value around the sample range boundaries
  37183. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37184. * @return Wrapped position in sample range
  37185. */
  37186. protected _wrapPosition(i: number): number;
  37187. }
  37188. }
  37189. declare module BABYLON {
  37190. /**
  37191. * This class is used to track a performance counter which is number based.
  37192. * The user has access to many properties which give statistics of different nature.
  37193. *
  37194. * The implementer can track two kinds of Performance Counter: time and count.
  37195. * 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.
  37196. * 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.
  37197. */
  37198. export class PerfCounter {
  37199. /**
  37200. * Gets or sets a global boolean to turn on and off all the counters
  37201. */
  37202. static Enabled: boolean;
  37203. /**
  37204. * Returns the smallest value ever
  37205. */
  37206. get min(): number;
  37207. /**
  37208. * Returns the biggest value ever
  37209. */
  37210. get max(): number;
  37211. /**
  37212. * Returns the average value since the performance counter is running
  37213. */
  37214. get average(): number;
  37215. /**
  37216. * Returns the average value of the last second the counter was monitored
  37217. */
  37218. get lastSecAverage(): number;
  37219. /**
  37220. * Returns the current value
  37221. */
  37222. get current(): number;
  37223. /**
  37224. * Gets the accumulated total
  37225. */
  37226. get total(): number;
  37227. /**
  37228. * Gets the total value count
  37229. */
  37230. get count(): number;
  37231. /**
  37232. * Creates a new counter
  37233. */
  37234. constructor();
  37235. /**
  37236. * Call this method to start monitoring a new frame.
  37237. * 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.
  37238. */
  37239. fetchNewFrame(): void;
  37240. /**
  37241. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37242. * @param newCount the count value to add to the monitored count
  37243. * @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.
  37244. */
  37245. addCount(newCount: number, fetchResult: boolean): void;
  37246. /**
  37247. * Start monitoring this performance counter
  37248. */
  37249. beginMonitoring(): void;
  37250. /**
  37251. * Compute the time lapsed since the previous beginMonitoring() call.
  37252. * @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
  37253. */
  37254. endMonitoring(newFrame?: boolean): void;
  37255. private _fetchResult;
  37256. private _startMonitoringTime;
  37257. private _min;
  37258. private _max;
  37259. private _average;
  37260. private _current;
  37261. private _totalValueCount;
  37262. private _totalAccumulated;
  37263. private _lastSecAverage;
  37264. private _lastSecAccumulated;
  37265. private _lastSecTime;
  37266. private _lastSecValueCount;
  37267. }
  37268. }
  37269. declare module BABYLON {
  37270. interface ThinEngine {
  37271. /** @hidden */
  37272. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37273. }
  37274. }
  37275. declare module BABYLON {
  37276. /**
  37277. * Defines the interface used by display changed events
  37278. */
  37279. export interface IDisplayChangedEventArgs {
  37280. /** Gets the vrDisplay object (if any) */
  37281. vrDisplay: Nullable<any>;
  37282. /** Gets a boolean indicating if webVR is supported */
  37283. vrSupported: boolean;
  37284. }
  37285. /**
  37286. * Defines the interface used by objects containing a viewport (like a camera)
  37287. */
  37288. interface IViewportOwnerLike {
  37289. /**
  37290. * Gets or sets the viewport
  37291. */
  37292. viewport: IViewportLike;
  37293. }
  37294. /**
  37295. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37296. */
  37297. export class Engine extends ThinEngine {
  37298. /** Defines that alpha blending is disabled */
  37299. static readonly ALPHA_DISABLE: number;
  37300. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37301. static readonly ALPHA_ADD: number;
  37302. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37303. static readonly ALPHA_COMBINE: number;
  37304. /** Defines that alpha blending to DEST - SRC * DEST */
  37305. static readonly ALPHA_SUBTRACT: number;
  37306. /** Defines that alpha blending to SRC * DEST */
  37307. static readonly ALPHA_MULTIPLY: number;
  37308. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37309. static readonly ALPHA_MAXIMIZED: number;
  37310. /** Defines that alpha blending to SRC + DEST */
  37311. static readonly ALPHA_ONEONE: number;
  37312. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37313. static readonly ALPHA_PREMULTIPLIED: number;
  37314. /**
  37315. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37316. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37317. */
  37318. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37319. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37320. static readonly ALPHA_INTERPOLATE: number;
  37321. /**
  37322. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37323. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37324. */
  37325. static readonly ALPHA_SCREENMODE: number;
  37326. /** Defines that the ressource is not delayed*/
  37327. static readonly DELAYLOADSTATE_NONE: number;
  37328. /** Defines that the ressource was successfully delay loaded */
  37329. static readonly DELAYLOADSTATE_LOADED: number;
  37330. /** Defines that the ressource is currently delay loading */
  37331. static readonly DELAYLOADSTATE_LOADING: number;
  37332. /** Defines that the ressource is delayed and has not started loading */
  37333. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37334. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37335. static readonly NEVER: number;
  37336. /** 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 */
  37337. static readonly ALWAYS: number;
  37338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37339. static readonly LESS: number;
  37340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37341. static readonly EQUAL: number;
  37342. /** 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 */
  37343. static readonly LEQUAL: number;
  37344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37345. static readonly GREATER: number;
  37346. /** 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 */
  37347. static readonly GEQUAL: number;
  37348. /** 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 */
  37349. static readonly NOTEQUAL: number;
  37350. /** Passed to stencilOperation to specify that stencil value must be kept */
  37351. static readonly KEEP: number;
  37352. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37353. static readonly REPLACE: number;
  37354. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37355. static readonly INCR: number;
  37356. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37357. static readonly DECR: number;
  37358. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37359. static readonly INVERT: number;
  37360. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37361. static readonly INCR_WRAP: number;
  37362. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37363. static readonly DECR_WRAP: number;
  37364. /** Texture is not repeating outside of 0..1 UVs */
  37365. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37366. /** Texture is repeating outside of 0..1 UVs */
  37367. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37368. /** Texture is repeating and mirrored */
  37369. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37370. /** ALPHA */
  37371. static readonly TEXTUREFORMAT_ALPHA: number;
  37372. /** LUMINANCE */
  37373. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37374. /** LUMINANCE_ALPHA */
  37375. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37376. /** RGB */
  37377. static readonly TEXTUREFORMAT_RGB: number;
  37378. /** RGBA */
  37379. static readonly TEXTUREFORMAT_RGBA: number;
  37380. /** RED */
  37381. static readonly TEXTUREFORMAT_RED: number;
  37382. /** RED (2nd reference) */
  37383. static readonly TEXTUREFORMAT_R: number;
  37384. /** RG */
  37385. static readonly TEXTUREFORMAT_RG: number;
  37386. /** RED_INTEGER */
  37387. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37388. /** RED_INTEGER (2nd reference) */
  37389. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37390. /** RG_INTEGER */
  37391. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37392. /** RGB_INTEGER */
  37393. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37394. /** RGBA_INTEGER */
  37395. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37396. /** UNSIGNED_BYTE */
  37397. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37398. /** UNSIGNED_BYTE (2nd reference) */
  37399. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37400. /** FLOAT */
  37401. static readonly TEXTURETYPE_FLOAT: number;
  37402. /** HALF_FLOAT */
  37403. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37404. /** BYTE */
  37405. static readonly TEXTURETYPE_BYTE: number;
  37406. /** SHORT */
  37407. static readonly TEXTURETYPE_SHORT: number;
  37408. /** UNSIGNED_SHORT */
  37409. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37410. /** INT */
  37411. static readonly TEXTURETYPE_INT: number;
  37412. /** UNSIGNED_INT */
  37413. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37414. /** UNSIGNED_SHORT_4_4_4_4 */
  37415. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37416. /** UNSIGNED_SHORT_5_5_5_1 */
  37417. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37418. /** UNSIGNED_SHORT_5_6_5 */
  37419. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37420. /** UNSIGNED_INT_2_10_10_10_REV */
  37421. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37422. /** UNSIGNED_INT_24_8 */
  37423. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37424. /** UNSIGNED_INT_10F_11F_11F_REV */
  37425. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37426. /** UNSIGNED_INT_5_9_9_9_REV */
  37427. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37428. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37429. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37430. /** nearest is mag = nearest and min = nearest and mip = linear */
  37431. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37432. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37433. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37434. /** Trilinear is mag = linear and min = linear and mip = linear */
  37435. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37436. /** nearest is mag = nearest and min = nearest and mip = linear */
  37437. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37439. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37440. /** Trilinear is mag = linear and min = linear and mip = linear */
  37441. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37442. /** mag = nearest and min = nearest and mip = nearest */
  37443. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37444. /** mag = nearest and min = linear and mip = nearest */
  37445. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37446. /** mag = nearest and min = linear and mip = linear */
  37447. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37448. /** mag = nearest and min = linear and mip = none */
  37449. static readonly TEXTURE_NEAREST_LINEAR: number;
  37450. /** mag = nearest and min = nearest and mip = none */
  37451. static readonly TEXTURE_NEAREST_NEAREST: number;
  37452. /** mag = linear and min = nearest and mip = nearest */
  37453. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37454. /** mag = linear and min = nearest and mip = linear */
  37455. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37456. /** mag = linear and min = linear and mip = none */
  37457. static readonly TEXTURE_LINEAR_LINEAR: number;
  37458. /** mag = linear and min = nearest and mip = none */
  37459. static readonly TEXTURE_LINEAR_NEAREST: number;
  37460. /** Explicit coordinates mode */
  37461. static readonly TEXTURE_EXPLICIT_MODE: number;
  37462. /** Spherical coordinates mode */
  37463. static readonly TEXTURE_SPHERICAL_MODE: number;
  37464. /** Planar coordinates mode */
  37465. static readonly TEXTURE_PLANAR_MODE: number;
  37466. /** Cubic coordinates mode */
  37467. static readonly TEXTURE_CUBIC_MODE: number;
  37468. /** Projection coordinates mode */
  37469. static readonly TEXTURE_PROJECTION_MODE: number;
  37470. /** Skybox coordinates mode */
  37471. static readonly TEXTURE_SKYBOX_MODE: number;
  37472. /** Inverse Cubic coordinates mode */
  37473. static readonly TEXTURE_INVCUBIC_MODE: number;
  37474. /** Equirectangular coordinates mode */
  37475. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37476. /** Equirectangular Fixed coordinates mode */
  37477. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37478. /** Equirectangular Fixed Mirrored coordinates mode */
  37479. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37480. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37481. static readonly SCALEMODE_FLOOR: number;
  37482. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37483. static readonly SCALEMODE_NEAREST: number;
  37484. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37485. static readonly SCALEMODE_CEILING: number;
  37486. /**
  37487. * Returns the current npm package of the sdk
  37488. */
  37489. static get NpmPackage(): string;
  37490. /**
  37491. * Returns the current version of the framework
  37492. */
  37493. static get Version(): string;
  37494. /** Gets the list of created engines */
  37495. static get Instances(): Engine[];
  37496. /**
  37497. * Gets the latest created engine
  37498. */
  37499. static get LastCreatedEngine(): Nullable<Engine>;
  37500. /**
  37501. * Gets the latest created scene
  37502. */
  37503. static get LastCreatedScene(): Nullable<Scene>;
  37504. /**
  37505. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37506. * @param flag defines which part of the materials must be marked as dirty
  37507. * @param predicate defines a predicate used to filter which materials should be affected
  37508. */
  37509. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37510. /**
  37511. * Method called to create the default loading screen.
  37512. * This can be overriden in your own app.
  37513. * @param canvas The rendering canvas element
  37514. * @returns The loading screen
  37515. */
  37516. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37517. /**
  37518. * Method called to create the default rescale post process on each engine.
  37519. */
  37520. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37521. /**
  37522. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37523. **/
  37524. enableOfflineSupport: boolean;
  37525. /**
  37526. * 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)
  37527. **/
  37528. disableManifestCheck: boolean;
  37529. /**
  37530. * Gets the list of created scenes
  37531. */
  37532. scenes: Scene[];
  37533. /**
  37534. * Event raised when a new scene is created
  37535. */
  37536. onNewSceneAddedObservable: Observable<Scene>;
  37537. /**
  37538. * Gets the list of created postprocesses
  37539. */
  37540. postProcesses: PostProcess[];
  37541. /**
  37542. * Gets a boolean indicating if the pointer is currently locked
  37543. */
  37544. isPointerLock: boolean;
  37545. /**
  37546. * Observable event triggered each time the rendering canvas is resized
  37547. */
  37548. onResizeObservable: Observable<Engine>;
  37549. /**
  37550. * Observable event triggered each time the canvas loses focus
  37551. */
  37552. onCanvasBlurObservable: Observable<Engine>;
  37553. /**
  37554. * Observable event triggered each time the canvas gains focus
  37555. */
  37556. onCanvasFocusObservable: Observable<Engine>;
  37557. /**
  37558. * Observable event triggered each time the canvas receives pointerout event
  37559. */
  37560. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37561. /**
  37562. * Observable raised when the engine begins a new frame
  37563. */
  37564. onBeginFrameObservable: Observable<Engine>;
  37565. /**
  37566. * If set, will be used to request the next animation frame for the render loop
  37567. */
  37568. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37569. /**
  37570. * Observable raised when the engine ends the current frame
  37571. */
  37572. onEndFrameObservable: Observable<Engine>;
  37573. /**
  37574. * Observable raised when the engine is about to compile a shader
  37575. */
  37576. onBeforeShaderCompilationObservable: Observable<Engine>;
  37577. /**
  37578. * Observable raised when the engine has jsut compiled a shader
  37579. */
  37580. onAfterShaderCompilationObservable: Observable<Engine>;
  37581. /**
  37582. * Gets the audio engine
  37583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37584. * @ignorenaming
  37585. */
  37586. static audioEngine: IAudioEngine;
  37587. /**
  37588. * Default AudioEngine factory responsible of creating the Audio Engine.
  37589. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37590. */
  37591. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37592. /**
  37593. * Default offline support factory responsible of creating a tool used to store data locally.
  37594. * By default, this will create a Database object if the workload has been embedded.
  37595. */
  37596. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37597. private _loadingScreen;
  37598. private _pointerLockRequested;
  37599. private _rescalePostProcess;
  37600. private _deterministicLockstep;
  37601. private _lockstepMaxSteps;
  37602. private _timeStep;
  37603. protected get _supportsHardwareTextureRescaling(): boolean;
  37604. private _fps;
  37605. private _deltaTime;
  37606. /** @hidden */
  37607. _drawCalls: PerfCounter;
  37608. /** 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 */
  37609. canvasTabIndex: number;
  37610. /**
  37611. * Turn this value on if you want to pause FPS computation when in background
  37612. */
  37613. disablePerformanceMonitorInBackground: boolean;
  37614. private _performanceMonitor;
  37615. /**
  37616. * Gets the performance monitor attached to this engine
  37617. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37618. */
  37619. get performanceMonitor(): PerformanceMonitor;
  37620. private _onFocus;
  37621. private _onBlur;
  37622. private _onCanvasPointerOut;
  37623. private _onCanvasBlur;
  37624. private _onCanvasFocus;
  37625. private _onFullscreenChange;
  37626. private _onPointerLockChange;
  37627. /**
  37628. * Gets the HTML element used to attach event listeners
  37629. * @returns a HTML element
  37630. */
  37631. getInputElement(): Nullable<HTMLElement>;
  37632. /**
  37633. * Creates a new engine
  37634. * @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
  37635. * @param antialias defines enable antialiasing (default: false)
  37636. * @param options defines further options to be sent to the getContext() function
  37637. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37638. */
  37639. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37640. /**
  37641. * Gets current aspect ratio
  37642. * @param viewportOwner defines the camera to use to get the aspect ratio
  37643. * @param useScreen defines if screen size must be used (or the current render target if any)
  37644. * @returns a number defining the aspect ratio
  37645. */
  37646. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37647. /**
  37648. * Gets current screen aspect ratio
  37649. * @returns a number defining the aspect ratio
  37650. */
  37651. getScreenAspectRatio(): number;
  37652. /**
  37653. * Gets the client rect of the HTML canvas attached with the current webGL context
  37654. * @returns a client rectanglee
  37655. */
  37656. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37657. /**
  37658. * Gets the client rect of the HTML element used for events
  37659. * @returns a client rectanglee
  37660. */
  37661. getInputElementClientRect(): Nullable<ClientRect>;
  37662. /**
  37663. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37664. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37665. * @returns true if engine is in deterministic lock step mode
  37666. */
  37667. isDeterministicLockStep(): boolean;
  37668. /**
  37669. * Gets the max steps when engine is running in deterministic lock step
  37670. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37671. * @returns the max steps
  37672. */
  37673. getLockstepMaxSteps(): number;
  37674. /**
  37675. * Returns the time in ms between steps when using deterministic lock step.
  37676. * @returns time step in (ms)
  37677. */
  37678. getTimeStep(): number;
  37679. /**
  37680. * Force the mipmap generation for the given render target texture
  37681. * @param texture defines the render target texture to use
  37682. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37683. */
  37684. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37685. /** States */
  37686. /**
  37687. * Set various states to the webGL context
  37688. * @param culling defines backface culling state
  37689. * @param zOffset defines the value to apply to zOffset (0 by default)
  37690. * @param force defines if states must be applied even if cache is up to date
  37691. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37692. */
  37693. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37694. /**
  37695. * Set the z offset to apply to current rendering
  37696. * @param value defines the offset to apply
  37697. */
  37698. setZOffset(value: number): void;
  37699. /**
  37700. * Gets the current value of the zOffset
  37701. * @returns the current zOffset state
  37702. */
  37703. getZOffset(): number;
  37704. /**
  37705. * Enable or disable depth buffering
  37706. * @param enable defines the state to set
  37707. */
  37708. setDepthBuffer(enable: boolean): void;
  37709. /**
  37710. * Gets a boolean indicating if depth writing is enabled
  37711. * @returns the current depth writing state
  37712. */
  37713. getDepthWrite(): boolean;
  37714. /**
  37715. * Enable or disable depth writing
  37716. * @param enable defines the state to set
  37717. */
  37718. setDepthWrite(enable: boolean): void;
  37719. /**
  37720. * Gets a boolean indicating if stencil buffer is enabled
  37721. * @returns the current stencil buffer state
  37722. */
  37723. getStencilBuffer(): boolean;
  37724. /**
  37725. * Enable or disable the stencil buffer
  37726. * @param enable defines if the stencil buffer must be enabled or disabled
  37727. */
  37728. setStencilBuffer(enable: boolean): void;
  37729. /**
  37730. * Gets the current stencil mask
  37731. * @returns a number defining the new stencil mask to use
  37732. */
  37733. getStencilMask(): number;
  37734. /**
  37735. * Sets the current stencil mask
  37736. * @param mask defines the new stencil mask to use
  37737. */
  37738. setStencilMask(mask: number): void;
  37739. /**
  37740. * Gets the current stencil function
  37741. * @returns a number defining the stencil function to use
  37742. */
  37743. getStencilFunction(): number;
  37744. /**
  37745. * Gets the current stencil reference value
  37746. * @returns a number defining the stencil reference value to use
  37747. */
  37748. getStencilFunctionReference(): number;
  37749. /**
  37750. * Gets the current stencil mask
  37751. * @returns a number defining the stencil mask to use
  37752. */
  37753. getStencilFunctionMask(): number;
  37754. /**
  37755. * Sets the current stencil function
  37756. * @param stencilFunc defines the new stencil function to use
  37757. */
  37758. setStencilFunction(stencilFunc: number): void;
  37759. /**
  37760. * Sets the current stencil reference
  37761. * @param reference defines the new stencil reference to use
  37762. */
  37763. setStencilFunctionReference(reference: number): void;
  37764. /**
  37765. * Sets the current stencil mask
  37766. * @param mask defines the new stencil mask to use
  37767. */
  37768. setStencilFunctionMask(mask: number): void;
  37769. /**
  37770. * Gets the current stencil operation when stencil fails
  37771. * @returns a number defining stencil operation to use when stencil fails
  37772. */
  37773. getStencilOperationFail(): number;
  37774. /**
  37775. * Gets the current stencil operation when depth fails
  37776. * @returns a number defining stencil operation to use when depth fails
  37777. */
  37778. getStencilOperationDepthFail(): number;
  37779. /**
  37780. * Gets the current stencil operation when stencil passes
  37781. * @returns a number defining stencil operation to use when stencil passes
  37782. */
  37783. getStencilOperationPass(): number;
  37784. /**
  37785. * Sets the stencil operation to use when stencil fails
  37786. * @param operation defines the stencil operation to use when stencil fails
  37787. */
  37788. setStencilOperationFail(operation: number): void;
  37789. /**
  37790. * Sets the stencil operation to use when depth fails
  37791. * @param operation defines the stencil operation to use when depth fails
  37792. */
  37793. setStencilOperationDepthFail(operation: number): void;
  37794. /**
  37795. * Sets the stencil operation to use when stencil passes
  37796. * @param operation defines the stencil operation to use when stencil passes
  37797. */
  37798. setStencilOperationPass(operation: number): void;
  37799. /**
  37800. * Sets a boolean indicating if the dithering state is enabled or disabled
  37801. * @param value defines the dithering state
  37802. */
  37803. setDitheringState(value: boolean): void;
  37804. /**
  37805. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37806. * @param value defines the rasterizer state
  37807. */
  37808. setRasterizerState(value: boolean): void;
  37809. /**
  37810. * Gets the current depth function
  37811. * @returns a number defining the depth function
  37812. */
  37813. getDepthFunction(): Nullable<number>;
  37814. /**
  37815. * Sets the current depth function
  37816. * @param depthFunc defines the function to use
  37817. */
  37818. setDepthFunction(depthFunc: number): void;
  37819. /**
  37820. * Sets the current depth function to GREATER
  37821. */
  37822. setDepthFunctionToGreater(): void;
  37823. /**
  37824. * Sets the current depth function to GEQUAL
  37825. */
  37826. setDepthFunctionToGreaterOrEqual(): void;
  37827. /**
  37828. * Sets the current depth function to LESS
  37829. */
  37830. setDepthFunctionToLess(): void;
  37831. /**
  37832. * Sets the current depth function to LEQUAL
  37833. */
  37834. setDepthFunctionToLessOrEqual(): void;
  37835. private _cachedStencilBuffer;
  37836. private _cachedStencilFunction;
  37837. private _cachedStencilMask;
  37838. private _cachedStencilOperationPass;
  37839. private _cachedStencilOperationFail;
  37840. private _cachedStencilOperationDepthFail;
  37841. private _cachedStencilReference;
  37842. /**
  37843. * Caches the the state of the stencil buffer
  37844. */
  37845. cacheStencilState(): void;
  37846. /**
  37847. * Restores the state of the stencil buffer
  37848. */
  37849. restoreStencilState(): void;
  37850. /**
  37851. * Directly set the WebGL Viewport
  37852. * @param x defines the x coordinate of the viewport (in screen space)
  37853. * @param y defines the y coordinate of the viewport (in screen space)
  37854. * @param width defines the width of the viewport (in screen space)
  37855. * @param height defines the height of the viewport (in screen space)
  37856. * @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
  37857. */
  37858. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37859. /**
  37860. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37861. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37862. * @param y defines the y-coordinate of the corner of the clear rectangle
  37863. * @param width defines the width of the clear rectangle
  37864. * @param height defines the height of the clear rectangle
  37865. * @param clearColor defines the clear color
  37866. */
  37867. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37868. /**
  37869. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37870. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37871. * @param y defines the y-coordinate of the corner of the clear rectangle
  37872. * @param width defines the width of the clear rectangle
  37873. * @param height defines the height of the clear rectangle
  37874. */
  37875. enableScissor(x: number, y: number, width: number, height: number): void;
  37876. /**
  37877. * Disable previously set scissor test rectangle
  37878. */
  37879. disableScissor(): void;
  37880. protected _reportDrawCall(): void;
  37881. /**
  37882. * Initializes a webVR display and starts listening to display change events
  37883. * The onVRDisplayChangedObservable will be notified upon these changes
  37884. * @returns The onVRDisplayChangedObservable
  37885. */
  37886. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37887. /** @hidden */
  37888. _prepareVRComponent(): void;
  37889. /** @hidden */
  37890. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37891. /** @hidden */
  37892. _submitVRFrame(): void;
  37893. /**
  37894. * Call this function to leave webVR mode
  37895. * Will do nothing if webVR is not supported or if there is no webVR device
  37896. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37897. */
  37898. disableVR(): void;
  37899. /**
  37900. * Gets a boolean indicating that the system is in VR mode and is presenting
  37901. * @returns true if VR mode is engaged
  37902. */
  37903. isVRPresenting(): boolean;
  37904. /** @hidden */
  37905. _requestVRFrame(): void;
  37906. /** @hidden */
  37907. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37908. /**
  37909. * Gets the source code of the vertex shader associated with a specific webGL program
  37910. * @param program defines the program to use
  37911. * @returns a string containing the source code of the vertex shader associated with the program
  37912. */
  37913. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37914. /**
  37915. * Gets the source code of the fragment shader associated with a specific webGL program
  37916. * @param program defines the program to use
  37917. * @returns a string containing the source code of the fragment shader associated with the program
  37918. */
  37919. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37920. /**
  37921. * Sets a depth stencil texture from a render target to the according uniform.
  37922. * @param channel The texture channel
  37923. * @param uniform The uniform to set
  37924. * @param texture The render target texture containing the depth stencil texture to apply
  37925. */
  37926. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37927. /**
  37928. * Sets a texture to the webGL context from a postprocess
  37929. * @param channel defines the channel to use
  37930. * @param postProcess defines the source postprocess
  37931. */
  37932. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37933. /**
  37934. * Binds the output of the passed in post process to the texture channel specified
  37935. * @param channel The channel the texture should be bound to
  37936. * @param postProcess The post process which's output should be bound
  37937. */
  37938. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37939. protected _rebuildBuffers(): void;
  37940. /** @hidden */
  37941. _renderFrame(): void;
  37942. _renderLoop(): void;
  37943. /** @hidden */
  37944. _renderViews(): boolean;
  37945. /**
  37946. * Toggle full screen mode
  37947. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37948. */
  37949. switchFullscreen(requestPointerLock: boolean): void;
  37950. /**
  37951. * Enters full screen mode
  37952. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37953. */
  37954. enterFullscreen(requestPointerLock: boolean): void;
  37955. /**
  37956. * Exits full screen mode
  37957. */
  37958. exitFullscreen(): void;
  37959. /**
  37960. * Enters Pointerlock mode
  37961. */
  37962. enterPointerlock(): void;
  37963. /**
  37964. * Exits Pointerlock mode
  37965. */
  37966. exitPointerlock(): void;
  37967. /**
  37968. * Begin a new frame
  37969. */
  37970. beginFrame(): void;
  37971. /**
  37972. * Enf the current frame
  37973. */
  37974. endFrame(): void;
  37975. resize(): void;
  37976. /**
  37977. * Force a specific size of the canvas
  37978. * @param width defines the new canvas' width
  37979. * @param height defines the new canvas' height
  37980. * @returns true if the size was changed
  37981. */
  37982. setSize(width: number, height: number): boolean;
  37983. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37984. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37985. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37986. _releaseTexture(texture: InternalTexture): void;
  37987. /**
  37988. * @hidden
  37989. * Rescales a texture
  37990. * @param source input texutre
  37991. * @param destination destination texture
  37992. * @param scene scene to use to render the resize
  37993. * @param internalFormat format to use when resizing
  37994. * @param onComplete callback to be called when resize has completed
  37995. */
  37996. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37997. /**
  37998. * Gets the current framerate
  37999. * @returns a number representing the framerate
  38000. */
  38001. getFps(): number;
  38002. /**
  38003. * Gets the time spent between current and previous frame
  38004. * @returns a number representing the delta time in ms
  38005. */
  38006. getDeltaTime(): number;
  38007. private _measureFps;
  38008. /** @hidden */
  38009. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38010. /**
  38011. * Updates the sample count of a render target texture
  38012. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38013. * @param texture defines the texture to update
  38014. * @param samples defines the sample count to set
  38015. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38016. */
  38017. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38018. /**
  38019. * Updates a depth texture Comparison Mode and Function.
  38020. * If the comparison Function is equal to 0, the mode will be set to none.
  38021. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38022. * @param texture The texture to set the comparison function for
  38023. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38024. */
  38025. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38026. /**
  38027. * Creates a webGL buffer to use with instanciation
  38028. * @param capacity defines the size of the buffer
  38029. * @returns the webGL buffer
  38030. */
  38031. createInstancesBuffer(capacity: number): DataBuffer;
  38032. /**
  38033. * Delete a webGL buffer used with instanciation
  38034. * @param buffer defines the webGL buffer to delete
  38035. */
  38036. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38037. private _clientWaitAsync;
  38038. /** @hidden */
  38039. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38040. dispose(): void;
  38041. private _disableTouchAction;
  38042. /**
  38043. * Display the loading screen
  38044. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38045. */
  38046. displayLoadingUI(): void;
  38047. /**
  38048. * Hide the loading screen
  38049. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38050. */
  38051. hideLoadingUI(): void;
  38052. /**
  38053. * Gets the current loading screen object
  38054. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38055. */
  38056. get loadingScreen(): ILoadingScreen;
  38057. /**
  38058. * Sets the current loading screen object
  38059. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38060. */
  38061. set loadingScreen(loadingScreen: ILoadingScreen);
  38062. /**
  38063. * Sets the current loading screen text
  38064. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38065. */
  38066. set loadingUIText(text: string);
  38067. /**
  38068. * Sets the current loading screen background color
  38069. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38070. */
  38071. set loadingUIBackgroundColor(color: string);
  38072. /** Pointerlock and fullscreen */
  38073. /**
  38074. * Ask the browser to promote the current element to pointerlock mode
  38075. * @param element defines the DOM element to promote
  38076. */
  38077. static _RequestPointerlock(element: HTMLElement): void;
  38078. /**
  38079. * Asks the browser to exit pointerlock mode
  38080. */
  38081. static _ExitPointerlock(): void;
  38082. /**
  38083. * Ask the browser to promote the current element to fullscreen rendering mode
  38084. * @param element defines the DOM element to promote
  38085. */
  38086. static _RequestFullscreen(element: HTMLElement): void;
  38087. /**
  38088. * Asks the browser to exit fullscreen mode
  38089. */
  38090. static _ExitFullscreen(): void;
  38091. }
  38092. }
  38093. declare module BABYLON {
  38094. /**
  38095. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38096. * during the life time of the application.
  38097. */
  38098. export class EngineStore {
  38099. /** Gets the list of created engines */
  38100. static Instances: Engine[];
  38101. /** @hidden */
  38102. static _LastCreatedScene: Nullable<Scene>;
  38103. /**
  38104. * Gets the latest created engine
  38105. */
  38106. static get LastCreatedEngine(): Nullable<Engine>;
  38107. /**
  38108. * Gets the latest created scene
  38109. */
  38110. static get LastCreatedScene(): Nullable<Scene>;
  38111. /**
  38112. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38113. * @ignorenaming
  38114. */
  38115. static UseFallbackTexture: boolean;
  38116. /**
  38117. * Texture content used if a texture cannot loaded
  38118. * @ignorenaming
  38119. */
  38120. static FallbackTexture: string;
  38121. }
  38122. }
  38123. declare module BABYLON {
  38124. /**
  38125. * Helper class that provides a small promise polyfill
  38126. */
  38127. export class PromisePolyfill {
  38128. /**
  38129. * Static function used to check if the polyfill is required
  38130. * If this is the case then the function will inject the polyfill to window.Promise
  38131. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38132. */
  38133. static Apply(force?: boolean): void;
  38134. }
  38135. }
  38136. declare module BABYLON {
  38137. /**
  38138. * Interface for screenshot methods with describe argument called `size` as object with options
  38139. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38140. */
  38141. export interface IScreenshotSize {
  38142. /**
  38143. * number in pixels for canvas height
  38144. */
  38145. height?: number;
  38146. /**
  38147. * multiplier allowing render at a higher or lower resolution
  38148. * If value is defined then height and width will be ignored and taken from camera
  38149. */
  38150. precision?: number;
  38151. /**
  38152. * number in pixels for canvas width
  38153. */
  38154. width?: number;
  38155. }
  38156. }
  38157. declare module BABYLON {
  38158. interface IColor4Like {
  38159. r: float;
  38160. g: float;
  38161. b: float;
  38162. a: float;
  38163. }
  38164. /**
  38165. * Class containing a set of static utilities functions
  38166. */
  38167. export class Tools {
  38168. /**
  38169. * Gets or sets the base URL to use to load assets
  38170. */
  38171. static get BaseUrl(): string;
  38172. static set BaseUrl(value: string);
  38173. /**
  38174. * Enable/Disable Custom HTTP Request Headers globally.
  38175. * default = false
  38176. * @see CustomRequestHeaders
  38177. */
  38178. static UseCustomRequestHeaders: boolean;
  38179. /**
  38180. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38181. * i.e. when loading files, where the server/service expects an Authorization header
  38182. */
  38183. static CustomRequestHeaders: {
  38184. [key: string]: string;
  38185. };
  38186. /**
  38187. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38188. */
  38189. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38190. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38191. /**
  38192. * Default behaviour for cors in the application.
  38193. * It can be a string if the expected behavior is identical in the entire app.
  38194. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38195. */
  38196. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38197. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38198. /**
  38199. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38200. * @ignorenaming
  38201. */
  38202. static get UseFallbackTexture(): boolean;
  38203. static set UseFallbackTexture(value: boolean);
  38204. /**
  38205. * Use this object to register external classes like custom textures or material
  38206. * to allow the laoders to instantiate them
  38207. */
  38208. static get RegisteredExternalClasses(): {
  38209. [key: string]: Object;
  38210. };
  38211. static set RegisteredExternalClasses(classes: {
  38212. [key: string]: Object;
  38213. });
  38214. /**
  38215. * Texture content used if a texture cannot loaded
  38216. * @ignorenaming
  38217. */
  38218. static get fallbackTexture(): string;
  38219. static set fallbackTexture(value: string);
  38220. /**
  38221. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38222. * @param u defines the coordinate on X axis
  38223. * @param v defines the coordinate on Y axis
  38224. * @param width defines the width of the source data
  38225. * @param height defines the height of the source data
  38226. * @param pixels defines the source byte array
  38227. * @param color defines the output color
  38228. */
  38229. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38230. /**
  38231. * Interpolates between a and b via alpha
  38232. * @param a The lower value (returned when alpha = 0)
  38233. * @param b The upper value (returned when alpha = 1)
  38234. * @param alpha The interpolation-factor
  38235. * @return The mixed value
  38236. */
  38237. static Mix(a: number, b: number, alpha: number): number;
  38238. /**
  38239. * Tries to instantiate a new object from a given class name
  38240. * @param className defines the class name to instantiate
  38241. * @returns the new object or null if the system was not able to do the instantiation
  38242. */
  38243. static Instantiate(className: string): any;
  38244. /**
  38245. * Provides a slice function that will work even on IE
  38246. * @param data defines the array to slice
  38247. * @param start defines the start of the data (optional)
  38248. * @param end defines the end of the data (optional)
  38249. * @returns the new sliced array
  38250. */
  38251. static Slice<T>(data: T, start?: number, end?: number): T;
  38252. /**
  38253. * Polyfill for setImmediate
  38254. * @param action defines the action to execute after the current execution block
  38255. */
  38256. static SetImmediate(action: () => void): void;
  38257. /**
  38258. * Function indicating if a number is an exponent of 2
  38259. * @param value defines the value to test
  38260. * @returns true if the value is an exponent of 2
  38261. */
  38262. static IsExponentOfTwo(value: number): boolean;
  38263. private static _tmpFloatArray;
  38264. /**
  38265. * Returns the nearest 32-bit single precision float representation of a Number
  38266. * @param value A Number. If the parameter is of a different type, it will get converted
  38267. * to a number or to NaN if it cannot be converted
  38268. * @returns number
  38269. */
  38270. static FloatRound(value: number): number;
  38271. /**
  38272. * Extracts the filename from a path
  38273. * @param path defines the path to use
  38274. * @returns the filename
  38275. */
  38276. static GetFilename(path: string): string;
  38277. /**
  38278. * Extracts the "folder" part of a path (everything before the filename).
  38279. * @param uri The URI to extract the info from
  38280. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38281. * @returns The "folder" part of the path
  38282. */
  38283. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38284. /**
  38285. * Extracts text content from a DOM element hierarchy
  38286. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38287. */
  38288. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38289. /**
  38290. * Convert an angle in radians to degrees
  38291. * @param angle defines the angle to convert
  38292. * @returns the angle in degrees
  38293. */
  38294. static ToDegrees(angle: number): number;
  38295. /**
  38296. * Convert an angle in degrees to radians
  38297. * @param angle defines the angle to convert
  38298. * @returns the angle in radians
  38299. */
  38300. static ToRadians(angle: number): number;
  38301. /**
  38302. * Returns an array if obj is not an array
  38303. * @param obj defines the object to evaluate as an array
  38304. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38305. * @returns either obj directly if obj is an array or a new array containing obj
  38306. */
  38307. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38308. /**
  38309. * Gets the pointer prefix to use
  38310. * @param engine defines the engine we are finding the prefix for
  38311. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38312. */
  38313. static GetPointerPrefix(engine: Engine): string;
  38314. /**
  38315. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38316. * @param url define the url we are trying
  38317. * @param element define the dom element where to configure the cors policy
  38318. */
  38319. static SetCorsBehavior(url: string | string[], element: {
  38320. crossOrigin: string | null;
  38321. }): void;
  38322. /**
  38323. * Removes unwanted characters from an url
  38324. * @param url defines the url to clean
  38325. * @returns the cleaned url
  38326. */
  38327. static CleanUrl(url: string): string;
  38328. /**
  38329. * Gets or sets a function used to pre-process url before using them to load assets
  38330. */
  38331. static get PreprocessUrl(): (url: string) => string;
  38332. static set PreprocessUrl(processor: (url: string) => string);
  38333. /**
  38334. * Loads an image as an HTMLImageElement.
  38335. * @param input url string, ArrayBuffer, or Blob to load
  38336. * @param onLoad callback called when the image successfully loads
  38337. * @param onError callback called when the image fails to load
  38338. * @param offlineProvider offline provider for caching
  38339. * @param mimeType optional mime type
  38340. * @returns the HTMLImageElement of the loaded image
  38341. */
  38342. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38343. /**
  38344. * Loads a file from a url
  38345. * @param url url string, ArrayBuffer, or Blob to load
  38346. * @param onSuccess callback called when the file successfully loads
  38347. * @param onProgress callback called while file is loading (if the server supports this mode)
  38348. * @param offlineProvider defines the offline provider for caching
  38349. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38350. * @param onError callback called when the file fails to load
  38351. * @returns a file request object
  38352. */
  38353. 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;
  38354. /**
  38355. * Loads a file from a url
  38356. * @param url the file url to load
  38357. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38358. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38359. */
  38360. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38361. /**
  38362. * Load a script (identified by an url). When the url returns, the
  38363. * content of this file is added into a new script element, attached to the DOM (body element)
  38364. * @param scriptUrl defines the url of the script to laod
  38365. * @param onSuccess defines the callback called when the script is loaded
  38366. * @param onError defines the callback to call if an error occurs
  38367. * @param scriptId defines the id of the script element
  38368. */
  38369. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38370. /**
  38371. * Load an asynchronous script (identified by an url). When the url returns, the
  38372. * content of this file is added into a new script element, attached to the DOM (body element)
  38373. * @param scriptUrl defines the url of the script to laod
  38374. * @param scriptId defines the id of the script element
  38375. * @returns a promise request object
  38376. */
  38377. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38378. /**
  38379. * Loads a file from a blob
  38380. * @param fileToLoad defines the blob to use
  38381. * @param callback defines the callback to call when data is loaded
  38382. * @param progressCallback defines the callback to call during loading process
  38383. * @returns a file request object
  38384. */
  38385. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38386. /**
  38387. * Reads a file from a File object
  38388. * @param file defines the file to load
  38389. * @param onSuccess defines the callback to call when data is loaded
  38390. * @param onProgress defines the callback to call during loading process
  38391. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38392. * @param onError defines the callback to call when an error occurs
  38393. * @returns a file request object
  38394. */
  38395. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38396. /**
  38397. * Creates a data url from a given string content
  38398. * @param content defines the content to convert
  38399. * @returns the new data url link
  38400. */
  38401. static FileAsURL(content: string): string;
  38402. /**
  38403. * Format the given number to a specific decimal format
  38404. * @param value defines the number to format
  38405. * @param decimals defines the number of decimals to use
  38406. * @returns the formatted string
  38407. */
  38408. static Format(value: number, decimals?: number): string;
  38409. /**
  38410. * Tries to copy an object by duplicating every property
  38411. * @param source defines the source object
  38412. * @param destination defines the target object
  38413. * @param doNotCopyList defines a list of properties to avoid
  38414. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38415. */
  38416. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38417. /**
  38418. * Gets a boolean indicating if the given object has no own property
  38419. * @param obj defines the object to test
  38420. * @returns true if object has no own property
  38421. */
  38422. static IsEmpty(obj: any): boolean;
  38423. /**
  38424. * Function used to register events at window level
  38425. * @param windowElement defines the Window object to use
  38426. * @param events defines the events to register
  38427. */
  38428. static RegisterTopRootEvents(windowElement: Window, events: {
  38429. name: string;
  38430. handler: Nullable<(e: FocusEvent) => any>;
  38431. }[]): void;
  38432. /**
  38433. * Function used to unregister events from window level
  38434. * @param windowElement defines the Window object to use
  38435. * @param events defines the events to unregister
  38436. */
  38437. static UnregisterTopRootEvents(windowElement: Window, events: {
  38438. name: string;
  38439. handler: Nullable<(e: FocusEvent) => any>;
  38440. }[]): void;
  38441. /**
  38442. * @ignore
  38443. */
  38444. static _ScreenshotCanvas: HTMLCanvasElement;
  38445. /**
  38446. * Dumps the current bound framebuffer
  38447. * @param width defines the rendering width
  38448. * @param height defines the rendering height
  38449. * @param engine defines the hosting engine
  38450. * @param successCallback defines the callback triggered once the data are available
  38451. * @param mimeType defines the mime type of the result
  38452. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38453. */
  38454. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38455. /**
  38456. * Converts the canvas data to blob.
  38457. * This acts as a polyfill for browsers not supporting the to blob function.
  38458. * @param canvas Defines the canvas to extract the data from
  38459. * @param successCallback Defines the callback triggered once the data are available
  38460. * @param mimeType Defines the mime type of the result
  38461. */
  38462. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38463. /**
  38464. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38465. * @param successCallback defines the callback triggered once the data are available
  38466. * @param mimeType defines the mime type of the result
  38467. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38468. */
  38469. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38470. /**
  38471. * Downloads a blob in the browser
  38472. * @param blob defines the blob to download
  38473. * @param fileName defines the name of the downloaded file
  38474. */
  38475. static Download(blob: Blob, fileName: string): void;
  38476. /**
  38477. * Captures a screenshot of the current rendering
  38478. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38479. * @param engine defines the rendering engine
  38480. * @param camera defines the source camera
  38481. * @param size This parameter can be set to a single number or to an object with the
  38482. * following (optional) properties: precision, width, height. If a single number is passed,
  38483. * it will be used for both width and height. If an object is passed, the screenshot size
  38484. * will be derived from the parameters. The precision property is a multiplier allowing
  38485. * rendering at a higher or lower resolution
  38486. * @param successCallback defines the callback receives a single parameter which contains the
  38487. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38488. * src parameter of an <img> to display it
  38489. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38490. * Check your browser for supported MIME types
  38491. */
  38492. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38493. /**
  38494. * Captures a screenshot of the current rendering
  38495. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38496. * @param engine defines the rendering engine
  38497. * @param camera defines the source camera
  38498. * @param size This parameter can be set to a single number or to an object with the
  38499. * following (optional) properties: precision, width, height. If a single number is passed,
  38500. * it will be used for both width and height. If an object is passed, the screenshot size
  38501. * will be derived from the parameters. The precision property is a multiplier allowing
  38502. * rendering at a higher or lower resolution
  38503. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38504. * Check your browser for supported MIME types
  38505. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38506. * to the src parameter of an <img> to display it
  38507. */
  38508. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38509. /**
  38510. * Generates an image screenshot from the specified camera.
  38511. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38512. * @param engine The engine to use for rendering
  38513. * @param camera The camera to use for rendering
  38514. * @param size This parameter can be set to a single number or to an object with the
  38515. * following (optional) properties: precision, width, height. If a single number is passed,
  38516. * it will be used for both width and height. If an object is passed, the screenshot size
  38517. * will be derived from the parameters. The precision property is a multiplier allowing
  38518. * rendering at a higher or lower resolution
  38519. * @param successCallback The callback receives a single parameter which contains the
  38520. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38521. * src parameter of an <img> to display it
  38522. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38523. * Check your browser for supported MIME types
  38524. * @param samples Texture samples (default: 1)
  38525. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38526. * @param fileName A name for for the downloaded file.
  38527. */
  38528. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38529. /**
  38530. * Generates an image screenshot from the specified camera.
  38531. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38532. * @param engine The engine to use for rendering
  38533. * @param camera The camera to use for rendering
  38534. * @param size This parameter can be set to a single number or to an object with the
  38535. * following (optional) properties: precision, width, height. If a single number is passed,
  38536. * it will be used for both width and height. If an object is passed, the screenshot size
  38537. * will be derived from the parameters. The precision property is a multiplier allowing
  38538. * rendering at a higher or lower resolution
  38539. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38540. * Check your browser for supported MIME types
  38541. * @param samples Texture samples (default: 1)
  38542. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38543. * @param fileName A name for for the downloaded file.
  38544. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38545. * to the src parameter of an <img> to display it
  38546. */
  38547. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38548. /**
  38549. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38550. * Be aware Math.random() could cause collisions, but:
  38551. * "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"
  38552. * @returns a pseudo random id
  38553. */
  38554. static RandomId(): string;
  38555. /**
  38556. * Test if the given uri is a base64 string
  38557. * @param uri The uri to test
  38558. * @return True if the uri is a base64 string or false otherwise
  38559. */
  38560. static IsBase64(uri: string): boolean;
  38561. /**
  38562. * Decode the given base64 uri.
  38563. * @param uri The uri to decode
  38564. * @return The decoded base64 data.
  38565. */
  38566. static DecodeBase64(uri: string): ArrayBuffer;
  38567. /**
  38568. * Gets the absolute url.
  38569. * @param url the input url
  38570. * @return the absolute url
  38571. */
  38572. static GetAbsoluteUrl(url: string): string;
  38573. /**
  38574. * No log
  38575. */
  38576. static readonly NoneLogLevel: number;
  38577. /**
  38578. * Only message logs
  38579. */
  38580. static readonly MessageLogLevel: number;
  38581. /**
  38582. * Only warning logs
  38583. */
  38584. static readonly WarningLogLevel: number;
  38585. /**
  38586. * Only error logs
  38587. */
  38588. static readonly ErrorLogLevel: number;
  38589. /**
  38590. * All logs
  38591. */
  38592. static readonly AllLogLevel: number;
  38593. /**
  38594. * Gets a value indicating the number of loading errors
  38595. * @ignorenaming
  38596. */
  38597. static get errorsCount(): number;
  38598. /**
  38599. * Callback called when a new log is added
  38600. */
  38601. static OnNewCacheEntry: (entry: string) => void;
  38602. /**
  38603. * Log a message to the console
  38604. * @param message defines the message to log
  38605. */
  38606. static Log(message: string): void;
  38607. /**
  38608. * Write a warning message to the console
  38609. * @param message defines the message to log
  38610. */
  38611. static Warn(message: string): void;
  38612. /**
  38613. * Write an error message to the console
  38614. * @param message defines the message to log
  38615. */
  38616. static Error(message: string): void;
  38617. /**
  38618. * Gets current log cache (list of logs)
  38619. */
  38620. static get LogCache(): string;
  38621. /**
  38622. * Clears the log cache
  38623. */
  38624. static ClearLogCache(): void;
  38625. /**
  38626. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38627. */
  38628. static set LogLevels(level: number);
  38629. /**
  38630. * Checks if the window object exists
  38631. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38632. */
  38633. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38634. /**
  38635. * No performance log
  38636. */
  38637. static readonly PerformanceNoneLogLevel: number;
  38638. /**
  38639. * Use user marks to log performance
  38640. */
  38641. static readonly PerformanceUserMarkLogLevel: number;
  38642. /**
  38643. * Log performance to the console
  38644. */
  38645. static readonly PerformanceConsoleLogLevel: number;
  38646. private static _performance;
  38647. /**
  38648. * Sets the current performance log level
  38649. */
  38650. static set PerformanceLogLevel(level: number);
  38651. private static _StartPerformanceCounterDisabled;
  38652. private static _EndPerformanceCounterDisabled;
  38653. private static _StartUserMark;
  38654. private static _EndUserMark;
  38655. private static _StartPerformanceConsole;
  38656. private static _EndPerformanceConsole;
  38657. /**
  38658. * Starts a performance counter
  38659. */
  38660. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38661. /**
  38662. * Ends a specific performance coutner
  38663. */
  38664. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38665. /**
  38666. * Gets either window.performance.now() if supported or Date.now() else
  38667. */
  38668. static get Now(): number;
  38669. /**
  38670. * This method will return the name of the class used to create the instance of the given object.
  38671. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38672. * @param object the object to get the class name from
  38673. * @param isType defines if the object is actually a type
  38674. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38675. */
  38676. static GetClassName(object: any, isType?: boolean): string;
  38677. /**
  38678. * Gets the first element of an array satisfying a given predicate
  38679. * @param array defines the array to browse
  38680. * @param predicate defines the predicate to use
  38681. * @returns null if not found or the element
  38682. */
  38683. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38684. /**
  38685. * This method will return the name of the full name of the class, including its owning module (if any).
  38686. * 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).
  38687. * @param object the object to get the class name from
  38688. * @param isType defines if the object is actually a type
  38689. * @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.
  38690. * @ignorenaming
  38691. */
  38692. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38693. /**
  38694. * Returns a promise that resolves after the given amount of time.
  38695. * @param delay Number of milliseconds to delay
  38696. * @returns Promise that resolves after the given amount of time
  38697. */
  38698. static DelayAsync(delay: number): Promise<void>;
  38699. /**
  38700. * Utility function to detect if the current user agent is Safari
  38701. * @returns whether or not the current user agent is safari
  38702. */
  38703. static IsSafari(): boolean;
  38704. }
  38705. /**
  38706. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38707. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38708. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38709. * @param name The name of the class, case should be preserved
  38710. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38711. */
  38712. export function className(name: string, module?: string): (target: Object) => void;
  38713. /**
  38714. * An implementation of a loop for asynchronous functions.
  38715. */
  38716. export class AsyncLoop {
  38717. /**
  38718. * Defines the number of iterations for the loop
  38719. */
  38720. iterations: number;
  38721. /**
  38722. * Defines the current index of the loop.
  38723. */
  38724. index: number;
  38725. private _done;
  38726. private _fn;
  38727. private _successCallback;
  38728. /**
  38729. * Constructor.
  38730. * @param iterations the number of iterations.
  38731. * @param func the function to run each iteration
  38732. * @param successCallback the callback that will be called upon succesful execution
  38733. * @param offset starting offset.
  38734. */
  38735. constructor(
  38736. /**
  38737. * Defines the number of iterations for the loop
  38738. */
  38739. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38740. /**
  38741. * Execute the next iteration. Must be called after the last iteration was finished.
  38742. */
  38743. executeNext(): void;
  38744. /**
  38745. * Break the loop and run the success callback.
  38746. */
  38747. breakLoop(): void;
  38748. /**
  38749. * Create and run an async loop.
  38750. * @param iterations the number of iterations.
  38751. * @param fn the function to run each iteration
  38752. * @param successCallback the callback that will be called upon succesful execution
  38753. * @param offset starting offset.
  38754. * @returns the created async loop object
  38755. */
  38756. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38757. /**
  38758. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38759. * @param iterations total number of iterations
  38760. * @param syncedIterations number of synchronous iterations in each async iteration.
  38761. * @param fn the function to call each iteration.
  38762. * @param callback a success call back that will be called when iterating stops.
  38763. * @param breakFunction a break condition (optional)
  38764. * @param timeout timeout settings for the setTimeout function. default - 0.
  38765. * @returns the created async loop object
  38766. */
  38767. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38768. }
  38769. }
  38770. declare module BABYLON {
  38771. /**
  38772. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38773. * The underlying implementation relies on an associative array to ensure the best performances.
  38774. * The value can be anything including 'null' but except 'undefined'
  38775. */
  38776. export class StringDictionary<T> {
  38777. /**
  38778. * This will clear this dictionary and copy the content from the 'source' one.
  38779. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38780. * @param source the dictionary to take the content from and copy to this dictionary
  38781. */
  38782. copyFrom(source: StringDictionary<T>): void;
  38783. /**
  38784. * Get a value based from its key
  38785. * @param key the given key to get the matching value from
  38786. * @return the value if found, otherwise undefined is returned
  38787. */
  38788. get(key: string): T | undefined;
  38789. /**
  38790. * Get a value from its key or add it if it doesn't exist.
  38791. * This method will ensure you that a given key/data will be present in the dictionary.
  38792. * @param key the given key to get the matching value from
  38793. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38794. * The factory will only be invoked if there's no data for the given key.
  38795. * @return the value corresponding to the key.
  38796. */
  38797. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38798. /**
  38799. * Get a value from its key if present in the dictionary otherwise add it
  38800. * @param key the key to get the value from
  38801. * @param val if there's no such key/value pair in the dictionary add it with this value
  38802. * @return the value corresponding to the key
  38803. */
  38804. getOrAdd(key: string, val: T): T;
  38805. /**
  38806. * Check if there's a given key in the dictionary
  38807. * @param key the key to check for
  38808. * @return true if the key is present, false otherwise
  38809. */
  38810. contains(key: string): boolean;
  38811. /**
  38812. * Add a new key and its corresponding value
  38813. * @param key the key to add
  38814. * @param value the value corresponding to the key
  38815. * @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
  38816. */
  38817. add(key: string, value: T): boolean;
  38818. /**
  38819. * Update a specific value associated to a key
  38820. * @param key defines the key to use
  38821. * @param value defines the value to store
  38822. * @returns true if the value was updated (or false if the key was not found)
  38823. */
  38824. set(key: string, value: T): boolean;
  38825. /**
  38826. * Get the element of the given key and remove it from the dictionary
  38827. * @param key defines the key to search
  38828. * @returns the value associated with the key or null if not found
  38829. */
  38830. getAndRemove(key: string): Nullable<T>;
  38831. /**
  38832. * Remove a key/value from the dictionary.
  38833. * @param key the key to remove
  38834. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38835. */
  38836. remove(key: string): boolean;
  38837. /**
  38838. * Clear the whole content of the dictionary
  38839. */
  38840. clear(): void;
  38841. /**
  38842. * Gets the current count
  38843. */
  38844. get count(): number;
  38845. /**
  38846. * Execute a callback on each key/val of the dictionary.
  38847. * Note that you can remove any element in this dictionary in the callback implementation
  38848. * @param callback the callback to execute on a given key/value pair
  38849. */
  38850. forEach(callback: (key: string, val: T) => void): void;
  38851. /**
  38852. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38853. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38854. * Note that you can remove any element in this dictionary in the callback implementation
  38855. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38856. * @returns the first item
  38857. */
  38858. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38859. private _count;
  38860. private _data;
  38861. }
  38862. }
  38863. declare module BABYLON {
  38864. /** @hidden */
  38865. export interface ICollisionCoordinator {
  38866. createCollider(): Collider;
  38867. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38868. init(scene: Scene): void;
  38869. }
  38870. /** @hidden */
  38871. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38872. private _scene;
  38873. private _scaledPosition;
  38874. private _scaledVelocity;
  38875. private _finalPosition;
  38876. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38877. createCollider(): Collider;
  38878. init(scene: Scene): void;
  38879. private _collideWithWorld;
  38880. }
  38881. }
  38882. declare module BABYLON {
  38883. /**
  38884. * Class used to manage all inputs for the scene.
  38885. */
  38886. export class InputManager {
  38887. /** The distance in pixel that you have to move to prevent some events */
  38888. static DragMovementThreshold: number;
  38889. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38890. static LongPressDelay: number;
  38891. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38892. static DoubleClickDelay: number;
  38893. /** If you need to check double click without raising a single click at first click, enable this flag */
  38894. static ExclusiveDoubleClickMode: boolean;
  38895. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  38896. private _alreadyAttached;
  38897. private _wheelEventName;
  38898. private _onPointerMove;
  38899. private _onPointerDown;
  38900. private _onPointerUp;
  38901. private _initClickEvent;
  38902. private _initActionManager;
  38903. private _delayedSimpleClick;
  38904. private _delayedSimpleClickTimeout;
  38905. private _previousDelayedSimpleClickTimeout;
  38906. private _meshPickProceed;
  38907. private _previousButtonPressed;
  38908. private _currentPickResult;
  38909. private _previousPickResult;
  38910. private _totalPointersPressed;
  38911. private _doubleClickOccured;
  38912. private _pointerOverMesh;
  38913. private _pickedDownMesh;
  38914. private _pickedUpMesh;
  38915. private _pointerX;
  38916. private _pointerY;
  38917. private _unTranslatedPointerX;
  38918. private _unTranslatedPointerY;
  38919. private _startingPointerPosition;
  38920. private _previousStartingPointerPosition;
  38921. private _startingPointerTime;
  38922. private _previousStartingPointerTime;
  38923. private _pointerCaptures;
  38924. private _onKeyDown;
  38925. private _onKeyUp;
  38926. private _onCanvasFocusObserver;
  38927. private _onCanvasBlurObserver;
  38928. private _scene;
  38929. /**
  38930. * Creates a new InputManager
  38931. * @param scene defines the hosting scene
  38932. */
  38933. constructor(scene: Scene);
  38934. /**
  38935. * Gets the mesh that is currently under the pointer
  38936. */
  38937. get meshUnderPointer(): Nullable<AbstractMesh>;
  38938. /**
  38939. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38940. */
  38941. get unTranslatedPointer(): Vector2;
  38942. /**
  38943. * Gets or sets the current on-screen X position of the pointer
  38944. */
  38945. get pointerX(): number;
  38946. set pointerX(value: number);
  38947. /**
  38948. * Gets or sets the current on-screen Y position of the pointer
  38949. */
  38950. get pointerY(): number;
  38951. set pointerY(value: number);
  38952. private _updatePointerPosition;
  38953. private _processPointerMove;
  38954. private _setRayOnPointerInfo;
  38955. private _checkPrePointerObservable;
  38956. /**
  38957. * Use this method to simulate a pointer move on a mesh
  38958. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38959. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38960. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38961. */
  38962. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38963. /**
  38964. * Use this method to simulate a pointer down on a mesh
  38965. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38966. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38967. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38968. */
  38969. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38970. private _processPointerDown;
  38971. /** @hidden */
  38972. _isPointerSwiping(): boolean;
  38973. /**
  38974. * Use this method to simulate a pointer up on a mesh
  38975. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38976. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38977. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38978. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38979. */
  38980. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38981. private _processPointerUp;
  38982. /**
  38983. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38984. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38985. * @returns true if the pointer was captured
  38986. */
  38987. isPointerCaptured(pointerId?: number): boolean;
  38988. /**
  38989. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38990. * @param attachUp defines if you want to attach events to pointerup
  38991. * @param attachDown defines if you want to attach events to pointerdown
  38992. * @param attachMove defines if you want to attach events to pointermove
  38993. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38994. */
  38995. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38996. /**
  38997. * Detaches all event handlers
  38998. */
  38999. detachControl(): void;
  39000. /**
  39001. * Force the value of meshUnderPointer
  39002. * @param mesh defines the mesh to use
  39003. */
  39004. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39005. /**
  39006. * Gets the mesh under the pointer
  39007. * @returns a Mesh or null if no mesh is under the pointer
  39008. */
  39009. getPointerOverMesh(): Nullable<AbstractMesh>;
  39010. }
  39011. }
  39012. declare module BABYLON {
  39013. /**
  39014. * This class defines the direct association between an animation and a target
  39015. */
  39016. export class TargetedAnimation {
  39017. /**
  39018. * Animation to perform
  39019. */
  39020. animation: Animation;
  39021. /**
  39022. * Target to animate
  39023. */
  39024. target: any;
  39025. /**
  39026. * Returns the string "TargetedAnimation"
  39027. * @returns "TargetedAnimation"
  39028. */
  39029. getClassName(): string;
  39030. /**
  39031. * Serialize the object
  39032. * @returns the JSON object representing the current entity
  39033. */
  39034. serialize(): any;
  39035. }
  39036. /**
  39037. * Use this class to create coordinated animations on multiple targets
  39038. */
  39039. export class AnimationGroup implements IDisposable {
  39040. /** The name of the animation group */
  39041. name: string;
  39042. private _scene;
  39043. private _targetedAnimations;
  39044. private _animatables;
  39045. private _from;
  39046. private _to;
  39047. private _isStarted;
  39048. private _isPaused;
  39049. private _speedRatio;
  39050. private _loopAnimation;
  39051. private _isAdditive;
  39052. /**
  39053. * Gets or sets the unique id of the node
  39054. */
  39055. uniqueId: number;
  39056. /**
  39057. * This observable will notify when one animation have ended
  39058. */
  39059. onAnimationEndObservable: Observable<TargetedAnimation>;
  39060. /**
  39061. * Observer raised when one animation loops
  39062. */
  39063. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39064. /**
  39065. * Observer raised when all animations have looped
  39066. */
  39067. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39068. /**
  39069. * This observable will notify when all animations have ended.
  39070. */
  39071. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39072. /**
  39073. * This observable will notify when all animations have paused.
  39074. */
  39075. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39076. /**
  39077. * This observable will notify when all animations are playing.
  39078. */
  39079. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39080. /**
  39081. * Gets the first frame
  39082. */
  39083. get from(): number;
  39084. /**
  39085. * Gets the last frame
  39086. */
  39087. get to(): number;
  39088. /**
  39089. * Define if the animations are started
  39090. */
  39091. get isStarted(): boolean;
  39092. /**
  39093. * Gets a value indicating that the current group is playing
  39094. */
  39095. get isPlaying(): boolean;
  39096. /**
  39097. * Gets or sets the speed ratio to use for all animations
  39098. */
  39099. get speedRatio(): number;
  39100. /**
  39101. * Gets or sets the speed ratio to use for all animations
  39102. */
  39103. set speedRatio(value: number);
  39104. /**
  39105. * Gets or sets if all animations should loop or not
  39106. */
  39107. get loopAnimation(): boolean;
  39108. set loopAnimation(value: boolean);
  39109. /**
  39110. * Gets or sets if all animations should be evaluated additively
  39111. */
  39112. get isAdditive(): boolean;
  39113. set isAdditive(value: boolean);
  39114. /**
  39115. * Gets the targeted animations for this animation group
  39116. */
  39117. get targetedAnimations(): Array<TargetedAnimation>;
  39118. /**
  39119. * returning the list of animatables controlled by this animation group.
  39120. */
  39121. get animatables(): Array<Animatable>;
  39122. /**
  39123. * Gets the list of target animations
  39124. */
  39125. get children(): TargetedAnimation[];
  39126. /**
  39127. * Instantiates a new Animation Group.
  39128. * This helps managing several animations at once.
  39129. * @see https://doc.babylonjs.com/how_to/group
  39130. * @param name Defines the name of the group
  39131. * @param scene Defines the scene the group belongs to
  39132. */
  39133. constructor(
  39134. /** The name of the animation group */
  39135. name: string, scene?: Nullable<Scene>);
  39136. /**
  39137. * Add an animation (with its target) in the group
  39138. * @param animation defines the animation we want to add
  39139. * @param target defines the target of the animation
  39140. * @returns the TargetedAnimation object
  39141. */
  39142. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39143. /**
  39144. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39145. * It can add constant keys at begin or end
  39146. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39147. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39148. * @returns the animation group
  39149. */
  39150. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39151. private _animationLoopCount;
  39152. private _animationLoopFlags;
  39153. private _processLoop;
  39154. /**
  39155. * Start all animations on given targets
  39156. * @param loop defines if animations must loop
  39157. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39158. * @param from defines the from key (optional)
  39159. * @param to defines the to key (optional)
  39160. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39161. * @returns the current animation group
  39162. */
  39163. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39164. /**
  39165. * Pause all animations
  39166. * @returns the animation group
  39167. */
  39168. pause(): AnimationGroup;
  39169. /**
  39170. * Play all animations to initial state
  39171. * This function will start() the animations if they were not started or will restart() them if they were paused
  39172. * @param loop defines if animations must loop
  39173. * @returns the animation group
  39174. */
  39175. play(loop?: boolean): AnimationGroup;
  39176. /**
  39177. * Reset all animations to initial state
  39178. * @returns the animation group
  39179. */
  39180. reset(): AnimationGroup;
  39181. /**
  39182. * Restart animations from key 0
  39183. * @returns the animation group
  39184. */
  39185. restart(): AnimationGroup;
  39186. /**
  39187. * Stop all animations
  39188. * @returns the animation group
  39189. */
  39190. stop(): AnimationGroup;
  39191. /**
  39192. * Set animation weight for all animatables
  39193. * @param weight defines the weight to use
  39194. * @return the animationGroup
  39195. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39196. */
  39197. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39198. /**
  39199. * Synchronize and normalize all animatables with a source animatable
  39200. * @param root defines the root animatable to synchronize with
  39201. * @return the animationGroup
  39202. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39203. */
  39204. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39205. /**
  39206. * Goes to a specific frame in this animation group
  39207. * @param frame the frame number to go to
  39208. * @return the animationGroup
  39209. */
  39210. goToFrame(frame: number): AnimationGroup;
  39211. /**
  39212. * Dispose all associated resources
  39213. */
  39214. dispose(): void;
  39215. private _checkAnimationGroupEnded;
  39216. /**
  39217. * Clone the current animation group and returns a copy
  39218. * @param newName defines the name of the new group
  39219. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39220. * @returns the new aniamtion group
  39221. */
  39222. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39223. /**
  39224. * Serializes the animationGroup to an object
  39225. * @returns Serialized object
  39226. */
  39227. serialize(): any;
  39228. /**
  39229. * Returns a new AnimationGroup object parsed from the source provided.
  39230. * @param parsedAnimationGroup defines the source
  39231. * @param scene defines the scene that will receive the animationGroup
  39232. * @returns a new AnimationGroup
  39233. */
  39234. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39235. /**
  39236. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39237. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39238. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39239. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39240. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39241. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39242. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39243. */
  39244. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39245. /**
  39246. * Returns the string "AnimationGroup"
  39247. * @returns "AnimationGroup"
  39248. */
  39249. getClassName(): string;
  39250. /**
  39251. * Creates a detailled string about the object
  39252. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39253. * @returns a string representing the object
  39254. */
  39255. toString(fullDetails?: boolean): string;
  39256. }
  39257. }
  39258. declare module BABYLON {
  39259. /**
  39260. * Define an interface for all classes that will hold resources
  39261. */
  39262. export interface IDisposable {
  39263. /**
  39264. * Releases all held resources
  39265. */
  39266. dispose(): void;
  39267. }
  39268. /** Interface defining initialization parameters for Scene class */
  39269. export interface SceneOptions {
  39270. /**
  39271. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39272. * It will improve performance when the number of geometries becomes important.
  39273. */
  39274. useGeometryUniqueIdsMap?: boolean;
  39275. /**
  39276. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39277. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39278. */
  39279. useMaterialMeshMap?: boolean;
  39280. /**
  39281. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39282. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39283. */
  39284. useClonedMeshMap?: boolean;
  39285. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39286. virtual?: boolean;
  39287. }
  39288. /**
  39289. * Represents a scene to be rendered by the engine.
  39290. * @see https://doc.babylonjs.com/features/scene
  39291. */
  39292. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39293. /** The fog is deactivated */
  39294. static readonly FOGMODE_NONE: number;
  39295. /** The fog density is following an exponential function */
  39296. static readonly FOGMODE_EXP: number;
  39297. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39298. static readonly FOGMODE_EXP2: number;
  39299. /** The fog density is following a linear function. */
  39300. static readonly FOGMODE_LINEAR: number;
  39301. /**
  39302. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39303. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39304. */
  39305. static MinDeltaTime: number;
  39306. /**
  39307. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39308. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39309. */
  39310. static MaxDeltaTime: number;
  39311. /**
  39312. * Factory used to create the default material.
  39313. * @param name The name of the material to create
  39314. * @param scene The scene to create the material for
  39315. * @returns The default material
  39316. */
  39317. static DefaultMaterialFactory(scene: Scene): Material;
  39318. /**
  39319. * Factory used to create the a collision coordinator.
  39320. * @returns The collision coordinator
  39321. */
  39322. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39323. /** @hidden */
  39324. _inputManager: InputManager;
  39325. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39326. cameraToUseForPointers: Nullable<Camera>;
  39327. /** @hidden */
  39328. readonly _isScene: boolean;
  39329. /** @hidden */
  39330. _blockEntityCollection: boolean;
  39331. /**
  39332. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39333. */
  39334. autoClear: boolean;
  39335. /**
  39336. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39337. */
  39338. autoClearDepthAndStencil: boolean;
  39339. /**
  39340. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39341. */
  39342. clearColor: Color4;
  39343. /**
  39344. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39345. */
  39346. ambientColor: Color3;
  39347. /**
  39348. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39349. * It should only be one of the following (if not the default embedded one):
  39350. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39351. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39352. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39353. * The material properties need to be setup according to the type of texture in use.
  39354. */
  39355. environmentBRDFTexture: BaseTexture;
  39356. /** @hidden */
  39357. protected _environmentTexture: Nullable<BaseTexture>;
  39358. /**
  39359. * Texture used in all pbr material as the reflection texture.
  39360. * As in the majority of the scene they are the same (exception for multi room and so on),
  39361. * this is easier to reference from here than from all the materials.
  39362. */
  39363. get environmentTexture(): Nullable<BaseTexture>;
  39364. /**
  39365. * Texture used in all pbr material as the reflection texture.
  39366. * As in the majority of the scene they are the same (exception for multi room and so on),
  39367. * this is easier to set here than in all the materials.
  39368. */
  39369. set environmentTexture(value: Nullable<BaseTexture>);
  39370. /** @hidden */
  39371. protected _environmentIntensity: number;
  39372. /**
  39373. * Intensity of the environment in all pbr material.
  39374. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39375. * As in the majority of the scene they are the same (exception for multi room and so on),
  39376. * this is easier to reference from here than from all the materials.
  39377. */
  39378. get environmentIntensity(): number;
  39379. /**
  39380. * Intensity of the environment in all pbr material.
  39381. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39382. * As in the majority of the scene they are the same (exception for multi room and so on),
  39383. * this is easier to set here than in all the materials.
  39384. */
  39385. set environmentIntensity(value: number);
  39386. /** @hidden */
  39387. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39388. /**
  39389. * Default image processing configuration used either in the rendering
  39390. * Forward main pass or through the imageProcessingPostProcess if present.
  39391. * As in the majority of the scene they are the same (exception for multi camera),
  39392. * this is easier to reference from here than from all the materials and post process.
  39393. *
  39394. * No setter as we it is a shared configuration, you can set the values instead.
  39395. */
  39396. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39397. private _forceWireframe;
  39398. /**
  39399. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39400. */
  39401. set forceWireframe(value: boolean);
  39402. get forceWireframe(): boolean;
  39403. private _skipFrustumClipping;
  39404. /**
  39405. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39406. */
  39407. set skipFrustumClipping(value: boolean);
  39408. get skipFrustumClipping(): boolean;
  39409. private _forcePointsCloud;
  39410. /**
  39411. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39412. */
  39413. set forcePointsCloud(value: boolean);
  39414. get forcePointsCloud(): boolean;
  39415. /**
  39416. * Gets or sets the active clipplane 1
  39417. */
  39418. clipPlane: Nullable<Plane>;
  39419. /**
  39420. * Gets or sets the active clipplane 2
  39421. */
  39422. clipPlane2: Nullable<Plane>;
  39423. /**
  39424. * Gets or sets the active clipplane 3
  39425. */
  39426. clipPlane3: Nullable<Plane>;
  39427. /**
  39428. * Gets or sets the active clipplane 4
  39429. */
  39430. clipPlane4: Nullable<Plane>;
  39431. /**
  39432. * Gets or sets the active clipplane 5
  39433. */
  39434. clipPlane5: Nullable<Plane>;
  39435. /**
  39436. * Gets or sets the active clipplane 6
  39437. */
  39438. clipPlane6: Nullable<Plane>;
  39439. /**
  39440. * Gets or sets a boolean indicating if animations are enabled
  39441. */
  39442. animationsEnabled: boolean;
  39443. private _animationPropertiesOverride;
  39444. /**
  39445. * Gets or sets the animation properties override
  39446. */
  39447. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39448. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39449. /**
  39450. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39451. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39452. */
  39453. useConstantAnimationDeltaTime: boolean;
  39454. /**
  39455. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39456. * Please note that it requires to run a ray cast through the scene on every frame
  39457. */
  39458. constantlyUpdateMeshUnderPointer: boolean;
  39459. /**
  39460. * Defines the HTML cursor to use when hovering over interactive elements
  39461. */
  39462. hoverCursor: string;
  39463. /**
  39464. * Defines the HTML default cursor to use (empty by default)
  39465. */
  39466. defaultCursor: string;
  39467. /**
  39468. * Defines whether cursors are handled by the scene.
  39469. */
  39470. doNotHandleCursors: boolean;
  39471. /**
  39472. * This is used to call preventDefault() on pointer down
  39473. * in order to block unwanted artifacts like system double clicks
  39474. */
  39475. preventDefaultOnPointerDown: boolean;
  39476. /**
  39477. * This is used to call preventDefault() on pointer up
  39478. * in order to block unwanted artifacts like system double clicks
  39479. */
  39480. preventDefaultOnPointerUp: boolean;
  39481. /**
  39482. * Gets or sets user defined metadata
  39483. */
  39484. metadata: any;
  39485. /**
  39486. * For internal use only. Please do not use.
  39487. */
  39488. reservedDataStore: any;
  39489. /**
  39490. * Gets the name of the plugin used to load this scene (null by default)
  39491. */
  39492. loadingPluginName: string;
  39493. /**
  39494. * Use this array to add regular expressions used to disable offline support for specific urls
  39495. */
  39496. disableOfflineSupportExceptionRules: RegExp[];
  39497. /**
  39498. * An event triggered when the scene is disposed.
  39499. */
  39500. onDisposeObservable: Observable<Scene>;
  39501. private _onDisposeObserver;
  39502. /** Sets a function to be executed when this scene is disposed. */
  39503. set onDispose(callback: () => void);
  39504. /**
  39505. * An event triggered before rendering the scene (right after animations and physics)
  39506. */
  39507. onBeforeRenderObservable: Observable<Scene>;
  39508. private _onBeforeRenderObserver;
  39509. /** Sets a function to be executed before rendering this scene */
  39510. set beforeRender(callback: Nullable<() => void>);
  39511. /**
  39512. * An event triggered after rendering the scene
  39513. */
  39514. onAfterRenderObservable: Observable<Scene>;
  39515. /**
  39516. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39517. */
  39518. onAfterRenderCameraObservable: Observable<Camera>;
  39519. private _onAfterRenderObserver;
  39520. /** Sets a function to be executed after rendering this scene */
  39521. set afterRender(callback: Nullable<() => void>);
  39522. /**
  39523. * An event triggered before animating the scene
  39524. */
  39525. onBeforeAnimationsObservable: Observable<Scene>;
  39526. /**
  39527. * An event triggered after animations processing
  39528. */
  39529. onAfterAnimationsObservable: Observable<Scene>;
  39530. /**
  39531. * An event triggered before draw calls are ready to be sent
  39532. */
  39533. onBeforeDrawPhaseObservable: Observable<Scene>;
  39534. /**
  39535. * An event triggered after draw calls have been sent
  39536. */
  39537. onAfterDrawPhaseObservable: Observable<Scene>;
  39538. /**
  39539. * An event triggered when the scene is ready
  39540. */
  39541. onReadyObservable: Observable<Scene>;
  39542. /**
  39543. * An event triggered before rendering a camera
  39544. */
  39545. onBeforeCameraRenderObservable: Observable<Camera>;
  39546. private _onBeforeCameraRenderObserver;
  39547. /** Sets a function to be executed before rendering a camera*/
  39548. set beforeCameraRender(callback: () => void);
  39549. /**
  39550. * An event triggered after rendering a camera
  39551. */
  39552. onAfterCameraRenderObservable: Observable<Camera>;
  39553. private _onAfterCameraRenderObserver;
  39554. /** Sets a function to be executed after rendering a camera*/
  39555. set afterCameraRender(callback: () => void);
  39556. /**
  39557. * An event triggered when active meshes evaluation is about to start
  39558. */
  39559. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39560. /**
  39561. * An event triggered when active meshes evaluation is done
  39562. */
  39563. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39564. /**
  39565. * An event triggered when particles rendering is about to start
  39566. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39567. */
  39568. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39569. /**
  39570. * An event triggered when particles rendering is done
  39571. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39572. */
  39573. onAfterParticlesRenderingObservable: Observable<Scene>;
  39574. /**
  39575. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39576. */
  39577. onDataLoadedObservable: Observable<Scene>;
  39578. /**
  39579. * An event triggered when a camera is created
  39580. */
  39581. onNewCameraAddedObservable: Observable<Camera>;
  39582. /**
  39583. * An event triggered when a camera is removed
  39584. */
  39585. onCameraRemovedObservable: Observable<Camera>;
  39586. /**
  39587. * An event triggered when a light is created
  39588. */
  39589. onNewLightAddedObservable: Observable<Light>;
  39590. /**
  39591. * An event triggered when a light is removed
  39592. */
  39593. onLightRemovedObservable: Observable<Light>;
  39594. /**
  39595. * An event triggered when a geometry is created
  39596. */
  39597. onNewGeometryAddedObservable: Observable<Geometry>;
  39598. /**
  39599. * An event triggered when a geometry is removed
  39600. */
  39601. onGeometryRemovedObservable: Observable<Geometry>;
  39602. /**
  39603. * An event triggered when a transform node is created
  39604. */
  39605. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39606. /**
  39607. * An event triggered when a transform node is removed
  39608. */
  39609. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39610. /**
  39611. * An event triggered when a mesh is created
  39612. */
  39613. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39614. /**
  39615. * An event triggered when a mesh is removed
  39616. */
  39617. onMeshRemovedObservable: Observable<AbstractMesh>;
  39618. /**
  39619. * An event triggered when a skeleton is created
  39620. */
  39621. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39622. /**
  39623. * An event triggered when a skeleton is removed
  39624. */
  39625. onSkeletonRemovedObservable: Observable<Skeleton>;
  39626. /**
  39627. * An event triggered when a material is created
  39628. */
  39629. onNewMaterialAddedObservable: Observable<Material>;
  39630. /**
  39631. * An event triggered when a material is removed
  39632. */
  39633. onMaterialRemovedObservable: Observable<Material>;
  39634. /**
  39635. * An event triggered when a texture is created
  39636. */
  39637. onNewTextureAddedObservable: Observable<BaseTexture>;
  39638. /**
  39639. * An event triggered when a texture is removed
  39640. */
  39641. onTextureRemovedObservable: Observable<BaseTexture>;
  39642. /**
  39643. * An event triggered when render targets are about to be rendered
  39644. * Can happen multiple times per frame.
  39645. */
  39646. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39647. /**
  39648. * An event triggered when render targets were rendered.
  39649. * Can happen multiple times per frame.
  39650. */
  39651. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39652. /**
  39653. * An event triggered before calculating deterministic simulation step
  39654. */
  39655. onBeforeStepObservable: Observable<Scene>;
  39656. /**
  39657. * An event triggered after calculating deterministic simulation step
  39658. */
  39659. onAfterStepObservable: Observable<Scene>;
  39660. /**
  39661. * An event triggered when the activeCamera property is updated
  39662. */
  39663. onActiveCameraChanged: Observable<Scene>;
  39664. /**
  39665. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39666. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39667. * 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)
  39668. */
  39669. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39670. /**
  39671. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39672. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39673. * 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)
  39674. */
  39675. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39676. /**
  39677. * This Observable will when a mesh has been imported into the scene.
  39678. */
  39679. onMeshImportedObservable: Observable<AbstractMesh>;
  39680. /**
  39681. * This Observable will when an animation file has been imported into the scene.
  39682. */
  39683. onAnimationFileImportedObservable: Observable<Scene>;
  39684. /**
  39685. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39686. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39687. */
  39688. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39689. /** @hidden */
  39690. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39691. /**
  39692. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39693. */
  39694. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39695. /**
  39696. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39697. */
  39698. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39699. /**
  39700. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39701. */
  39702. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39703. /** Callback called when a pointer move is detected */
  39704. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39705. /** Callback called when a pointer down is detected */
  39706. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39707. /** Callback called when a pointer up is detected */
  39708. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39709. /** Callback called when a pointer pick is detected */
  39710. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39711. /**
  39712. * 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).
  39713. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39714. */
  39715. onPrePointerObservable: Observable<PointerInfoPre>;
  39716. /**
  39717. * Observable event triggered each time an input event is received from the rendering canvas
  39718. */
  39719. onPointerObservable: Observable<PointerInfo>;
  39720. /**
  39721. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39722. */
  39723. get unTranslatedPointer(): Vector2;
  39724. /**
  39725. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39726. */
  39727. static get DragMovementThreshold(): number;
  39728. static set DragMovementThreshold(value: number);
  39729. /**
  39730. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39731. */
  39732. static get LongPressDelay(): number;
  39733. static set LongPressDelay(value: number);
  39734. /**
  39735. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39736. */
  39737. static get DoubleClickDelay(): number;
  39738. static set DoubleClickDelay(value: number);
  39739. /** If you need to check double click without raising a single click at first click, enable this flag */
  39740. static get ExclusiveDoubleClickMode(): boolean;
  39741. static set ExclusiveDoubleClickMode(value: boolean);
  39742. /** @hidden */
  39743. _mirroredCameraPosition: Nullable<Vector3>;
  39744. /**
  39745. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39746. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39747. */
  39748. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39749. /**
  39750. * Observable event triggered each time an keyboard event is received from the hosting window
  39751. */
  39752. onKeyboardObservable: Observable<KeyboardInfo>;
  39753. private _useRightHandedSystem;
  39754. /**
  39755. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39756. */
  39757. set useRightHandedSystem(value: boolean);
  39758. get useRightHandedSystem(): boolean;
  39759. private _timeAccumulator;
  39760. private _currentStepId;
  39761. private _currentInternalStep;
  39762. /**
  39763. * Sets the step Id used by deterministic lock step
  39764. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39765. * @param newStepId defines the step Id
  39766. */
  39767. setStepId(newStepId: number): void;
  39768. /**
  39769. * Gets the step Id used by deterministic lock step
  39770. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39771. * @returns the step Id
  39772. */
  39773. getStepId(): number;
  39774. /**
  39775. * Gets the internal step used by deterministic lock step
  39776. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39777. * @returns the internal step
  39778. */
  39779. getInternalStep(): number;
  39780. private _fogEnabled;
  39781. /**
  39782. * Gets or sets a boolean indicating if fog is enabled on this scene
  39783. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39784. * (Default is true)
  39785. */
  39786. set fogEnabled(value: boolean);
  39787. get fogEnabled(): boolean;
  39788. private _fogMode;
  39789. /**
  39790. * Gets or sets the fog mode to use
  39791. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39792. * | mode | value |
  39793. * | --- | --- |
  39794. * | FOGMODE_NONE | 0 |
  39795. * | FOGMODE_EXP | 1 |
  39796. * | FOGMODE_EXP2 | 2 |
  39797. * | FOGMODE_LINEAR | 3 |
  39798. */
  39799. set fogMode(value: number);
  39800. get fogMode(): number;
  39801. /**
  39802. * Gets or sets the fog color to use
  39803. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39804. * (Default is Color3(0.2, 0.2, 0.3))
  39805. */
  39806. fogColor: Color3;
  39807. /**
  39808. * Gets or sets the fog density to use
  39809. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39810. * (Default is 0.1)
  39811. */
  39812. fogDensity: number;
  39813. /**
  39814. * Gets or sets the fog start distance to use
  39815. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39816. * (Default is 0)
  39817. */
  39818. fogStart: number;
  39819. /**
  39820. * Gets or sets the fog end distance to use
  39821. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39822. * (Default is 1000)
  39823. */
  39824. fogEnd: number;
  39825. /**
  39826. * Flag indicating that the frame buffer binding is handled by another component
  39827. */
  39828. prePass: boolean;
  39829. private _shadowsEnabled;
  39830. /**
  39831. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39832. */
  39833. set shadowsEnabled(value: boolean);
  39834. get shadowsEnabled(): boolean;
  39835. private _lightsEnabled;
  39836. /**
  39837. * Gets or sets a boolean indicating if lights are enabled on this scene
  39838. */
  39839. set lightsEnabled(value: boolean);
  39840. get lightsEnabled(): boolean;
  39841. /** All of the active cameras added to this scene. */
  39842. activeCameras: Camera[];
  39843. /** @hidden */
  39844. _activeCamera: Nullable<Camera>;
  39845. /** Gets or sets the current active camera */
  39846. get activeCamera(): Nullable<Camera>;
  39847. set activeCamera(value: Nullable<Camera>);
  39848. private _defaultMaterial;
  39849. /** The default material used on meshes when no material is affected */
  39850. get defaultMaterial(): Material;
  39851. /** The default material used on meshes when no material is affected */
  39852. set defaultMaterial(value: Material);
  39853. private _texturesEnabled;
  39854. /**
  39855. * Gets or sets a boolean indicating if textures are enabled on this scene
  39856. */
  39857. set texturesEnabled(value: boolean);
  39858. get texturesEnabled(): boolean;
  39859. /**
  39860. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39861. */
  39862. physicsEnabled: boolean;
  39863. /**
  39864. * Gets or sets a boolean indicating if particles are enabled on this scene
  39865. */
  39866. particlesEnabled: boolean;
  39867. /**
  39868. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39869. */
  39870. spritesEnabled: boolean;
  39871. private _skeletonsEnabled;
  39872. /**
  39873. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39874. */
  39875. set skeletonsEnabled(value: boolean);
  39876. get skeletonsEnabled(): boolean;
  39877. /**
  39878. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39879. */
  39880. lensFlaresEnabled: boolean;
  39881. /**
  39882. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39883. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39884. */
  39885. collisionsEnabled: boolean;
  39886. private _collisionCoordinator;
  39887. /** @hidden */
  39888. get collisionCoordinator(): ICollisionCoordinator;
  39889. /**
  39890. * Defines the gravity applied to this scene (used only for collisions)
  39891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39892. */
  39893. gravity: Vector3;
  39894. /**
  39895. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39896. */
  39897. postProcessesEnabled: boolean;
  39898. /**
  39899. * Gets the current postprocess manager
  39900. */
  39901. postProcessManager: PostProcessManager;
  39902. /**
  39903. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39904. */
  39905. renderTargetsEnabled: boolean;
  39906. /**
  39907. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39908. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39909. */
  39910. dumpNextRenderTargets: boolean;
  39911. /**
  39912. * The list of user defined render targets added to the scene
  39913. */
  39914. customRenderTargets: RenderTargetTexture[];
  39915. /**
  39916. * Defines if texture loading must be delayed
  39917. * If true, textures will only be loaded when they need to be rendered
  39918. */
  39919. useDelayedTextureLoading: boolean;
  39920. /**
  39921. * Gets the list of meshes imported to the scene through SceneLoader
  39922. */
  39923. importedMeshesFiles: String[];
  39924. /**
  39925. * Gets or sets a boolean indicating if probes are enabled on this scene
  39926. */
  39927. probesEnabled: boolean;
  39928. /**
  39929. * Gets or sets the current offline provider to use to store scene data
  39930. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39931. */
  39932. offlineProvider: IOfflineProvider;
  39933. /**
  39934. * Gets or sets the action manager associated with the scene
  39935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39936. */
  39937. actionManager: AbstractActionManager;
  39938. private _meshesForIntersections;
  39939. /**
  39940. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39941. */
  39942. proceduralTexturesEnabled: boolean;
  39943. private _engine;
  39944. private _totalVertices;
  39945. /** @hidden */
  39946. _activeIndices: PerfCounter;
  39947. /** @hidden */
  39948. _activeParticles: PerfCounter;
  39949. /** @hidden */
  39950. _activeBones: PerfCounter;
  39951. private _animationRatio;
  39952. /** @hidden */
  39953. _animationTimeLast: number;
  39954. /** @hidden */
  39955. _animationTime: number;
  39956. /**
  39957. * Gets or sets a general scale for animation speed
  39958. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39959. */
  39960. animationTimeScale: number;
  39961. /** @hidden */
  39962. _cachedMaterial: Nullable<Material>;
  39963. /** @hidden */
  39964. _cachedEffect: Nullable<Effect>;
  39965. /** @hidden */
  39966. _cachedVisibility: Nullable<number>;
  39967. private _renderId;
  39968. private _frameId;
  39969. private _executeWhenReadyTimeoutId;
  39970. private _intermediateRendering;
  39971. private _viewUpdateFlag;
  39972. private _projectionUpdateFlag;
  39973. /** @hidden */
  39974. _toBeDisposed: Nullable<IDisposable>[];
  39975. private _activeRequests;
  39976. /** @hidden */
  39977. _pendingData: any[];
  39978. private _isDisposed;
  39979. /**
  39980. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39981. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39982. */
  39983. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39984. private _activeMeshes;
  39985. private _processedMaterials;
  39986. private _renderTargets;
  39987. /** @hidden */
  39988. _activeParticleSystems: SmartArray<IParticleSystem>;
  39989. private _activeSkeletons;
  39990. private _softwareSkinnedMeshes;
  39991. private _renderingManager;
  39992. /** @hidden */
  39993. _activeAnimatables: Animatable[];
  39994. private _transformMatrix;
  39995. private _sceneUbo;
  39996. /** @hidden */
  39997. _viewMatrix: Matrix;
  39998. private _projectionMatrix;
  39999. /** @hidden */
  40000. _forcedViewPosition: Nullable<Vector3>;
  40001. /** @hidden */
  40002. _frustumPlanes: Plane[];
  40003. /**
  40004. * Gets the list of frustum planes (built from the active camera)
  40005. */
  40006. get frustumPlanes(): Plane[];
  40007. /**
  40008. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40009. * This is useful if there are more lights that the maximum simulteanous authorized
  40010. */
  40011. requireLightSorting: boolean;
  40012. /** @hidden */
  40013. readonly useMaterialMeshMap: boolean;
  40014. /** @hidden */
  40015. readonly useClonedMeshMap: boolean;
  40016. private _externalData;
  40017. private _uid;
  40018. /**
  40019. * @hidden
  40020. * Backing store of defined scene components.
  40021. */
  40022. _components: ISceneComponent[];
  40023. /**
  40024. * @hidden
  40025. * Backing store of defined scene components.
  40026. */
  40027. _serializableComponents: ISceneSerializableComponent[];
  40028. /**
  40029. * List of components to register on the next registration step.
  40030. */
  40031. private _transientComponents;
  40032. /**
  40033. * Registers the transient components if needed.
  40034. */
  40035. private _registerTransientComponents;
  40036. /**
  40037. * @hidden
  40038. * Add a component to the scene.
  40039. * Note that the ccomponent could be registered on th next frame if this is called after
  40040. * the register component stage.
  40041. * @param component Defines the component to add to the scene
  40042. */
  40043. _addComponent(component: ISceneComponent): void;
  40044. /**
  40045. * @hidden
  40046. * Gets a component from the scene.
  40047. * @param name defines the name of the component to retrieve
  40048. * @returns the component or null if not present
  40049. */
  40050. _getComponent(name: string): Nullable<ISceneComponent>;
  40051. /**
  40052. * @hidden
  40053. * Defines the actions happening before camera updates.
  40054. */
  40055. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40056. /**
  40057. * @hidden
  40058. * Defines the actions happening before clear the canvas.
  40059. */
  40060. _beforeClearStage: Stage<SimpleStageAction>;
  40061. /**
  40062. * @hidden
  40063. * Defines the actions when collecting render targets for the frame.
  40064. */
  40065. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40066. /**
  40067. * @hidden
  40068. * Defines the actions happening for one camera in the frame.
  40069. */
  40070. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40071. /**
  40072. * @hidden
  40073. * Defines the actions happening during the per mesh ready checks.
  40074. */
  40075. _isReadyForMeshStage: Stage<MeshStageAction>;
  40076. /**
  40077. * @hidden
  40078. * Defines the actions happening before evaluate active mesh checks.
  40079. */
  40080. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40081. /**
  40082. * @hidden
  40083. * Defines the actions happening during the evaluate sub mesh checks.
  40084. */
  40085. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40086. /**
  40087. * @hidden
  40088. * Defines the actions happening during the active mesh stage.
  40089. */
  40090. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40091. /**
  40092. * @hidden
  40093. * Defines the actions happening during the per camera render target step.
  40094. */
  40095. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40096. /**
  40097. * @hidden
  40098. * Defines the actions happening just before the active camera is drawing.
  40099. */
  40100. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40101. /**
  40102. * @hidden
  40103. * Defines the actions happening just before a render target is drawing.
  40104. */
  40105. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40106. /**
  40107. * @hidden
  40108. * Defines the actions happening just before a rendering group is drawing.
  40109. */
  40110. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40111. /**
  40112. * @hidden
  40113. * Defines the actions happening just before a mesh is drawing.
  40114. */
  40115. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40116. /**
  40117. * @hidden
  40118. * Defines the actions happening just after a mesh has been drawn.
  40119. */
  40120. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40121. /**
  40122. * @hidden
  40123. * Defines the actions happening just after a rendering group has been drawn.
  40124. */
  40125. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40126. /**
  40127. * @hidden
  40128. * Defines the actions happening just after the active camera has been drawn.
  40129. */
  40130. _afterCameraDrawStage: Stage<CameraStageAction>;
  40131. /**
  40132. * @hidden
  40133. * Defines the actions happening just after a render target has been drawn.
  40134. */
  40135. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40136. /**
  40137. * @hidden
  40138. * Defines the actions happening just after rendering all cameras and computing intersections.
  40139. */
  40140. _afterRenderStage: Stage<SimpleStageAction>;
  40141. /**
  40142. * @hidden
  40143. * Defines the actions happening when a pointer move event happens.
  40144. */
  40145. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40146. /**
  40147. * @hidden
  40148. * Defines the actions happening when a pointer down event happens.
  40149. */
  40150. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40151. /**
  40152. * @hidden
  40153. * Defines the actions happening when a pointer up event happens.
  40154. */
  40155. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40156. /**
  40157. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40158. */
  40159. private geometriesByUniqueId;
  40160. /**
  40161. * Creates a new Scene
  40162. * @param engine defines the engine to use to render this scene
  40163. * @param options defines the scene options
  40164. */
  40165. constructor(engine: Engine, options?: SceneOptions);
  40166. /**
  40167. * Gets a string identifying the name of the class
  40168. * @returns "Scene" string
  40169. */
  40170. getClassName(): string;
  40171. private _defaultMeshCandidates;
  40172. /**
  40173. * @hidden
  40174. */
  40175. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40176. private _defaultSubMeshCandidates;
  40177. /**
  40178. * @hidden
  40179. */
  40180. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40181. /**
  40182. * Sets the default candidate providers for the scene.
  40183. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40184. * and getCollidingSubMeshCandidates to their default function
  40185. */
  40186. setDefaultCandidateProviders(): void;
  40187. /**
  40188. * Gets the mesh that is currently under the pointer
  40189. */
  40190. get meshUnderPointer(): Nullable<AbstractMesh>;
  40191. /**
  40192. * Gets or sets the current on-screen X position of the pointer
  40193. */
  40194. get pointerX(): number;
  40195. set pointerX(value: number);
  40196. /**
  40197. * Gets or sets the current on-screen Y position of the pointer
  40198. */
  40199. get pointerY(): number;
  40200. set pointerY(value: number);
  40201. /**
  40202. * Gets the cached material (ie. the latest rendered one)
  40203. * @returns the cached material
  40204. */
  40205. getCachedMaterial(): Nullable<Material>;
  40206. /**
  40207. * Gets the cached effect (ie. the latest rendered one)
  40208. * @returns the cached effect
  40209. */
  40210. getCachedEffect(): Nullable<Effect>;
  40211. /**
  40212. * Gets the cached visibility state (ie. the latest rendered one)
  40213. * @returns the cached visibility state
  40214. */
  40215. getCachedVisibility(): Nullable<number>;
  40216. /**
  40217. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40218. * @param material defines the current material
  40219. * @param effect defines the current effect
  40220. * @param visibility defines the current visibility state
  40221. * @returns true if one parameter is not cached
  40222. */
  40223. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40224. /**
  40225. * Gets the engine associated with the scene
  40226. * @returns an Engine
  40227. */
  40228. getEngine(): Engine;
  40229. /**
  40230. * Gets the total number of vertices rendered per frame
  40231. * @returns the total number of vertices rendered per frame
  40232. */
  40233. getTotalVertices(): number;
  40234. /**
  40235. * Gets the performance counter for total vertices
  40236. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40237. */
  40238. get totalVerticesPerfCounter(): PerfCounter;
  40239. /**
  40240. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40241. * @returns the total number of active indices rendered per frame
  40242. */
  40243. getActiveIndices(): number;
  40244. /**
  40245. * Gets the performance counter for active indices
  40246. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40247. */
  40248. get totalActiveIndicesPerfCounter(): PerfCounter;
  40249. /**
  40250. * Gets the total number of active particles rendered per frame
  40251. * @returns the total number of active particles rendered per frame
  40252. */
  40253. getActiveParticles(): number;
  40254. /**
  40255. * Gets the performance counter for active particles
  40256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40257. */
  40258. get activeParticlesPerfCounter(): PerfCounter;
  40259. /**
  40260. * Gets the total number of active bones rendered per frame
  40261. * @returns the total number of active bones rendered per frame
  40262. */
  40263. getActiveBones(): number;
  40264. /**
  40265. * Gets the performance counter for active bones
  40266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40267. */
  40268. get activeBonesPerfCounter(): PerfCounter;
  40269. /**
  40270. * Gets the array of active meshes
  40271. * @returns an array of AbstractMesh
  40272. */
  40273. getActiveMeshes(): SmartArray<AbstractMesh>;
  40274. /**
  40275. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40276. * @returns a number
  40277. */
  40278. getAnimationRatio(): number;
  40279. /**
  40280. * Gets an unique Id for the current render phase
  40281. * @returns a number
  40282. */
  40283. getRenderId(): number;
  40284. /**
  40285. * Gets an unique Id for the current frame
  40286. * @returns a number
  40287. */
  40288. getFrameId(): number;
  40289. /** Call this function if you want to manually increment the render Id*/
  40290. incrementRenderId(): void;
  40291. private _createUbo;
  40292. /**
  40293. * Use this method to simulate a pointer move on a mesh
  40294. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40295. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40296. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40297. * @returns the current scene
  40298. */
  40299. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40300. /**
  40301. * Use this method to simulate a pointer down on a mesh
  40302. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40303. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40304. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40305. * @returns the current scene
  40306. */
  40307. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40308. /**
  40309. * Use this method to simulate a pointer up on a mesh
  40310. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40311. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40312. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40313. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40314. * @returns the current scene
  40315. */
  40316. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40317. /**
  40318. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40319. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40320. * @returns true if the pointer was captured
  40321. */
  40322. isPointerCaptured(pointerId?: number): boolean;
  40323. /**
  40324. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40325. * @param attachUp defines if you want to attach events to pointerup
  40326. * @param attachDown defines if you want to attach events to pointerdown
  40327. * @param attachMove defines if you want to attach events to pointermove
  40328. */
  40329. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40330. /** Detaches all event handlers*/
  40331. detachControl(): void;
  40332. /**
  40333. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40334. * Delay loaded resources are not taking in account
  40335. * @return true if all required resources are ready
  40336. */
  40337. isReady(): boolean;
  40338. /** Resets all cached information relative to material (including effect and visibility) */
  40339. resetCachedMaterial(): void;
  40340. /**
  40341. * Registers a function to be called before every frame render
  40342. * @param func defines the function to register
  40343. */
  40344. registerBeforeRender(func: () => void): void;
  40345. /**
  40346. * Unregisters a function called before every frame render
  40347. * @param func defines the function to unregister
  40348. */
  40349. unregisterBeforeRender(func: () => void): void;
  40350. /**
  40351. * Registers a function to be called after every frame render
  40352. * @param func defines the function to register
  40353. */
  40354. registerAfterRender(func: () => void): void;
  40355. /**
  40356. * Unregisters a function called after every frame render
  40357. * @param func defines the function to unregister
  40358. */
  40359. unregisterAfterRender(func: () => void): void;
  40360. private _executeOnceBeforeRender;
  40361. /**
  40362. * The provided function will run before render once and will be disposed afterwards.
  40363. * A timeout delay can be provided so that the function will be executed in N ms.
  40364. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40365. * @param func The function to be executed.
  40366. * @param timeout optional delay in ms
  40367. */
  40368. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40369. /** @hidden */
  40370. _addPendingData(data: any): void;
  40371. /** @hidden */
  40372. _removePendingData(data: any): void;
  40373. /**
  40374. * Returns the number of items waiting to be loaded
  40375. * @returns the number of items waiting to be loaded
  40376. */
  40377. getWaitingItemsCount(): number;
  40378. /**
  40379. * Returns a boolean indicating if the scene is still loading data
  40380. */
  40381. get isLoading(): boolean;
  40382. /**
  40383. * Registers a function to be executed when the scene is ready
  40384. * @param {Function} func - the function to be executed
  40385. */
  40386. executeWhenReady(func: () => void): void;
  40387. /**
  40388. * Returns a promise that resolves when the scene is ready
  40389. * @returns A promise that resolves when the scene is ready
  40390. */
  40391. whenReadyAsync(): Promise<void>;
  40392. /** @hidden */
  40393. _checkIsReady(): void;
  40394. /**
  40395. * Gets all animatable attached to the scene
  40396. */
  40397. get animatables(): Animatable[];
  40398. /**
  40399. * Resets the last animation time frame.
  40400. * Useful to override when animations start running when loading a scene for the first time.
  40401. */
  40402. resetLastAnimationTimeFrame(): void;
  40403. /**
  40404. * Gets the current view matrix
  40405. * @returns a Matrix
  40406. */
  40407. getViewMatrix(): Matrix;
  40408. /**
  40409. * Gets the current projection matrix
  40410. * @returns a Matrix
  40411. */
  40412. getProjectionMatrix(): Matrix;
  40413. /**
  40414. * Gets the current transform matrix
  40415. * @returns a Matrix made of View * Projection
  40416. */
  40417. getTransformMatrix(): Matrix;
  40418. /**
  40419. * Sets the current transform matrix
  40420. * @param viewL defines the View matrix to use
  40421. * @param projectionL defines the Projection matrix to use
  40422. * @param viewR defines the right View matrix to use (if provided)
  40423. * @param projectionR defines the right Projection matrix to use (if provided)
  40424. */
  40425. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40426. /**
  40427. * Gets the uniform buffer used to store scene data
  40428. * @returns a UniformBuffer
  40429. */
  40430. getSceneUniformBuffer(): UniformBuffer;
  40431. /**
  40432. * Gets an unique (relatively to the current scene) Id
  40433. * @returns an unique number for the scene
  40434. */
  40435. getUniqueId(): number;
  40436. /**
  40437. * Add a mesh to the list of scene's meshes
  40438. * @param newMesh defines the mesh to add
  40439. * @param recursive if all child meshes should also be added to the scene
  40440. */
  40441. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40442. /**
  40443. * Remove a mesh for the list of scene's meshes
  40444. * @param toRemove defines the mesh to remove
  40445. * @param recursive if all child meshes should also be removed from the scene
  40446. * @returns the index where the mesh was in the mesh list
  40447. */
  40448. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40449. /**
  40450. * Add a transform node to the list of scene's transform nodes
  40451. * @param newTransformNode defines the transform node to add
  40452. */
  40453. addTransformNode(newTransformNode: TransformNode): void;
  40454. /**
  40455. * Remove a transform node for the list of scene's transform nodes
  40456. * @param toRemove defines the transform node to remove
  40457. * @returns the index where the transform node was in the transform node list
  40458. */
  40459. removeTransformNode(toRemove: TransformNode): number;
  40460. /**
  40461. * Remove a skeleton for the list of scene's skeletons
  40462. * @param toRemove defines the skeleton to remove
  40463. * @returns the index where the skeleton was in the skeleton list
  40464. */
  40465. removeSkeleton(toRemove: Skeleton): number;
  40466. /**
  40467. * Remove a morph target for the list of scene's morph targets
  40468. * @param toRemove defines the morph target to remove
  40469. * @returns the index where the morph target was in the morph target list
  40470. */
  40471. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40472. /**
  40473. * Remove a light for the list of scene's lights
  40474. * @param toRemove defines the light to remove
  40475. * @returns the index where the light was in the light list
  40476. */
  40477. removeLight(toRemove: Light): number;
  40478. /**
  40479. * Remove a camera for the list of scene's cameras
  40480. * @param toRemove defines the camera to remove
  40481. * @returns the index where the camera was in the camera list
  40482. */
  40483. removeCamera(toRemove: Camera): number;
  40484. /**
  40485. * Remove a particle system for the list of scene's particle systems
  40486. * @param toRemove defines the particle system to remove
  40487. * @returns the index where the particle system was in the particle system list
  40488. */
  40489. removeParticleSystem(toRemove: IParticleSystem): number;
  40490. /**
  40491. * Remove a animation for the list of scene's animations
  40492. * @param toRemove defines the animation to remove
  40493. * @returns the index where the animation was in the animation list
  40494. */
  40495. removeAnimation(toRemove: Animation): number;
  40496. /**
  40497. * Will stop the animation of the given target
  40498. * @param target - the target
  40499. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40500. * @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)
  40501. */
  40502. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40503. /**
  40504. * Removes the given animation group from this scene.
  40505. * @param toRemove The animation group to remove
  40506. * @returns The index of the removed animation group
  40507. */
  40508. removeAnimationGroup(toRemove: AnimationGroup): number;
  40509. /**
  40510. * Removes the given multi-material from this scene.
  40511. * @param toRemove The multi-material to remove
  40512. * @returns The index of the removed multi-material
  40513. */
  40514. removeMultiMaterial(toRemove: MultiMaterial): number;
  40515. /**
  40516. * Removes the given material from this scene.
  40517. * @param toRemove The material to remove
  40518. * @returns The index of the removed material
  40519. */
  40520. removeMaterial(toRemove: Material): number;
  40521. /**
  40522. * Removes the given action manager from this scene.
  40523. * @param toRemove The action manager to remove
  40524. * @returns The index of the removed action manager
  40525. */
  40526. removeActionManager(toRemove: AbstractActionManager): number;
  40527. /**
  40528. * Removes the given texture from this scene.
  40529. * @param toRemove The texture to remove
  40530. * @returns The index of the removed texture
  40531. */
  40532. removeTexture(toRemove: BaseTexture): number;
  40533. /**
  40534. * Adds the given light to this scene
  40535. * @param newLight The light to add
  40536. */
  40537. addLight(newLight: Light): void;
  40538. /**
  40539. * Sorts the list list based on light priorities
  40540. */
  40541. sortLightsByPriority(): void;
  40542. /**
  40543. * Adds the given camera to this scene
  40544. * @param newCamera The camera to add
  40545. */
  40546. addCamera(newCamera: Camera): void;
  40547. /**
  40548. * Adds the given skeleton to this scene
  40549. * @param newSkeleton The skeleton to add
  40550. */
  40551. addSkeleton(newSkeleton: Skeleton): void;
  40552. /**
  40553. * Adds the given particle system to this scene
  40554. * @param newParticleSystem The particle system to add
  40555. */
  40556. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40557. /**
  40558. * Adds the given animation to this scene
  40559. * @param newAnimation The animation to add
  40560. */
  40561. addAnimation(newAnimation: Animation): void;
  40562. /**
  40563. * Adds the given animation group to this scene.
  40564. * @param newAnimationGroup The animation group to add
  40565. */
  40566. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40567. /**
  40568. * Adds the given multi-material to this scene
  40569. * @param newMultiMaterial The multi-material to add
  40570. */
  40571. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40572. /**
  40573. * Adds the given material to this scene
  40574. * @param newMaterial The material to add
  40575. */
  40576. addMaterial(newMaterial: Material): void;
  40577. /**
  40578. * Adds the given morph target to this scene
  40579. * @param newMorphTargetManager The morph target to add
  40580. */
  40581. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40582. /**
  40583. * Adds the given geometry to this scene
  40584. * @param newGeometry The geometry to add
  40585. */
  40586. addGeometry(newGeometry: Geometry): void;
  40587. /**
  40588. * Adds the given action manager to this scene
  40589. * @param newActionManager The action manager to add
  40590. */
  40591. addActionManager(newActionManager: AbstractActionManager): void;
  40592. /**
  40593. * Adds the given texture to this scene.
  40594. * @param newTexture The texture to add
  40595. */
  40596. addTexture(newTexture: BaseTexture): void;
  40597. /**
  40598. * Switch active camera
  40599. * @param newCamera defines the new active camera
  40600. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40601. */
  40602. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40603. /**
  40604. * sets the active camera of the scene using its ID
  40605. * @param id defines the camera's ID
  40606. * @return the new active camera or null if none found.
  40607. */
  40608. setActiveCameraByID(id: string): Nullable<Camera>;
  40609. /**
  40610. * sets the active camera of the scene using its name
  40611. * @param name defines the camera's name
  40612. * @returns the new active camera or null if none found.
  40613. */
  40614. setActiveCameraByName(name: string): Nullable<Camera>;
  40615. /**
  40616. * get an animation group using its name
  40617. * @param name defines the material's name
  40618. * @return the animation group or null if none found.
  40619. */
  40620. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40621. /**
  40622. * Get a material using its unique id
  40623. * @param uniqueId defines the material's unique id
  40624. * @return the material or null if none found.
  40625. */
  40626. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40627. /**
  40628. * get a material using its id
  40629. * @param id defines the material's ID
  40630. * @return the material or null if none found.
  40631. */
  40632. getMaterialByID(id: string): Nullable<Material>;
  40633. /**
  40634. * Gets a the last added material using a given id
  40635. * @param id defines the material's ID
  40636. * @return the last material with the given id or null if none found.
  40637. */
  40638. getLastMaterialByID(id: string): Nullable<Material>;
  40639. /**
  40640. * Gets a material using its name
  40641. * @param name defines the material's name
  40642. * @return the material or null if none found.
  40643. */
  40644. getMaterialByName(name: string): Nullable<Material>;
  40645. /**
  40646. * Get a texture using its unique id
  40647. * @param uniqueId defines the texture's unique id
  40648. * @return the texture or null if none found.
  40649. */
  40650. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40651. /**
  40652. * Gets a camera using its id
  40653. * @param id defines the id to look for
  40654. * @returns the camera or null if not found
  40655. */
  40656. getCameraByID(id: string): Nullable<Camera>;
  40657. /**
  40658. * Gets a camera using its unique id
  40659. * @param uniqueId defines the unique id to look for
  40660. * @returns the camera or null if not found
  40661. */
  40662. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40663. /**
  40664. * Gets a camera using its name
  40665. * @param name defines the camera's name
  40666. * @return the camera or null if none found.
  40667. */
  40668. getCameraByName(name: string): Nullable<Camera>;
  40669. /**
  40670. * Gets a bone using its id
  40671. * @param id defines the bone's id
  40672. * @return the bone or null if not found
  40673. */
  40674. getBoneByID(id: string): Nullable<Bone>;
  40675. /**
  40676. * Gets a bone using its id
  40677. * @param name defines the bone's name
  40678. * @return the bone or null if not found
  40679. */
  40680. getBoneByName(name: string): Nullable<Bone>;
  40681. /**
  40682. * Gets a light node using its name
  40683. * @param name defines the the light's name
  40684. * @return the light or null if none found.
  40685. */
  40686. getLightByName(name: string): Nullable<Light>;
  40687. /**
  40688. * Gets a light node using its id
  40689. * @param id defines the light's id
  40690. * @return the light or null if none found.
  40691. */
  40692. getLightByID(id: string): Nullable<Light>;
  40693. /**
  40694. * Gets a light node using its scene-generated unique ID
  40695. * @param uniqueId defines the light's unique id
  40696. * @return the light or null if none found.
  40697. */
  40698. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40699. /**
  40700. * Gets a particle system by id
  40701. * @param id defines the particle system id
  40702. * @return the corresponding system or null if none found
  40703. */
  40704. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40705. /**
  40706. * Gets a geometry using its ID
  40707. * @param id defines the geometry's id
  40708. * @return the geometry or null if none found.
  40709. */
  40710. getGeometryByID(id: string): Nullable<Geometry>;
  40711. private _getGeometryByUniqueID;
  40712. /**
  40713. * Add a new geometry to this scene
  40714. * @param geometry defines the geometry to be added to the scene.
  40715. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40716. * @return a boolean defining if the geometry was added or not
  40717. */
  40718. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40719. /**
  40720. * Removes an existing geometry
  40721. * @param geometry defines the geometry to be removed from the scene
  40722. * @return a boolean defining if the geometry was removed or not
  40723. */
  40724. removeGeometry(geometry: Geometry): boolean;
  40725. /**
  40726. * Gets the list of geometries attached to the scene
  40727. * @returns an array of Geometry
  40728. */
  40729. getGeometries(): Geometry[];
  40730. /**
  40731. * Gets the first added mesh found of a given ID
  40732. * @param id defines the id to search for
  40733. * @return the mesh found or null if not found at all
  40734. */
  40735. getMeshByID(id: string): Nullable<AbstractMesh>;
  40736. /**
  40737. * Gets a list of meshes using their id
  40738. * @param id defines the id to search for
  40739. * @returns a list of meshes
  40740. */
  40741. getMeshesByID(id: string): Array<AbstractMesh>;
  40742. /**
  40743. * Gets the first added transform node found of a given ID
  40744. * @param id defines the id to search for
  40745. * @return the found transform node or null if not found at all.
  40746. */
  40747. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40748. /**
  40749. * Gets a transform node with its auto-generated unique id
  40750. * @param uniqueId efines the unique id to search for
  40751. * @return the found transform node or null if not found at all.
  40752. */
  40753. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40754. /**
  40755. * Gets a list of transform nodes using their id
  40756. * @param id defines the id to search for
  40757. * @returns a list of transform nodes
  40758. */
  40759. getTransformNodesByID(id: string): Array<TransformNode>;
  40760. /**
  40761. * Gets a mesh with its auto-generated unique id
  40762. * @param uniqueId defines the unique id to search for
  40763. * @return the found mesh or null if not found at all.
  40764. */
  40765. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40766. /**
  40767. * Gets a the last added mesh using a given id
  40768. * @param id defines the id to search for
  40769. * @return the found mesh or null if not found at all.
  40770. */
  40771. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40772. /**
  40773. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40774. * @param id defines the id to search for
  40775. * @return the found node or null if not found at all
  40776. */
  40777. getLastEntryByID(id: string): Nullable<Node>;
  40778. /**
  40779. * Gets a node (Mesh, Camera, Light) using a given id
  40780. * @param id defines the id to search for
  40781. * @return the found node or null if not found at all
  40782. */
  40783. getNodeByID(id: string): Nullable<Node>;
  40784. /**
  40785. * Gets a node (Mesh, Camera, Light) using a given name
  40786. * @param name defines the name to search for
  40787. * @return the found node or null if not found at all.
  40788. */
  40789. getNodeByName(name: string): Nullable<Node>;
  40790. /**
  40791. * Gets a mesh using a given name
  40792. * @param name defines the name to search for
  40793. * @return the found mesh or null if not found at all.
  40794. */
  40795. getMeshByName(name: string): Nullable<AbstractMesh>;
  40796. /**
  40797. * Gets a transform node using a given name
  40798. * @param name defines the name to search for
  40799. * @return the found transform node or null if not found at all.
  40800. */
  40801. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40802. /**
  40803. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40804. * @param id defines the id to search for
  40805. * @return the found skeleton or null if not found at all.
  40806. */
  40807. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40808. /**
  40809. * Gets a skeleton using a given auto generated unique id
  40810. * @param uniqueId defines the unique id to search for
  40811. * @return the found skeleton or null if not found at all.
  40812. */
  40813. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40814. /**
  40815. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40816. * @param id defines the id to search for
  40817. * @return the found skeleton or null if not found at all.
  40818. */
  40819. getSkeletonById(id: string): Nullable<Skeleton>;
  40820. /**
  40821. * Gets a skeleton using a given name
  40822. * @param name defines the name to search for
  40823. * @return the found skeleton or null if not found at all.
  40824. */
  40825. getSkeletonByName(name: string): Nullable<Skeleton>;
  40826. /**
  40827. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40828. * @param id defines the id to search for
  40829. * @return the found morph target manager or null if not found at all.
  40830. */
  40831. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40832. /**
  40833. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40834. * @param id defines the id to search for
  40835. * @return the found morph target or null if not found at all.
  40836. */
  40837. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40838. /**
  40839. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40840. * @param name defines the name to search for
  40841. * @return the found morph target or null if not found at all.
  40842. */
  40843. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40844. /**
  40845. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40846. * @param name defines the name to search for
  40847. * @return the found post process or null if not found at all.
  40848. */
  40849. getPostProcessByName(name: string): Nullable<PostProcess>;
  40850. /**
  40851. * Gets a boolean indicating if the given mesh is active
  40852. * @param mesh defines the mesh to look for
  40853. * @returns true if the mesh is in the active list
  40854. */
  40855. isActiveMesh(mesh: AbstractMesh): boolean;
  40856. /**
  40857. * Return a unique id as a string which can serve as an identifier for the scene
  40858. */
  40859. get uid(): string;
  40860. /**
  40861. * Add an externaly attached data from its key.
  40862. * This method call will fail and return false, if such key already exists.
  40863. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40864. * @param key the unique key that identifies the data
  40865. * @param data the data object to associate to the key for this Engine instance
  40866. * @return true if no such key were already present and the data was added successfully, false otherwise
  40867. */
  40868. addExternalData<T>(key: string, data: T): boolean;
  40869. /**
  40870. * Get an externaly attached data from its key
  40871. * @param key the unique key that identifies the data
  40872. * @return the associated data, if present (can be null), or undefined if not present
  40873. */
  40874. getExternalData<T>(key: string): Nullable<T>;
  40875. /**
  40876. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40877. * @param key the unique key that identifies the data
  40878. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40879. * @return the associated data, can be null if the factory returned null.
  40880. */
  40881. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40882. /**
  40883. * Remove an externaly attached data from the Engine instance
  40884. * @param key the unique key that identifies the data
  40885. * @return true if the data was successfully removed, false if it doesn't exist
  40886. */
  40887. removeExternalData(key: string): boolean;
  40888. private _evaluateSubMesh;
  40889. /**
  40890. * Clear the processed materials smart array preventing retention point in material dispose.
  40891. */
  40892. freeProcessedMaterials(): void;
  40893. private _preventFreeActiveMeshesAndRenderingGroups;
  40894. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40895. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40896. * when disposing several meshes in a row or a hierarchy of meshes.
  40897. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40898. */
  40899. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40900. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40901. /**
  40902. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40903. */
  40904. freeActiveMeshes(): void;
  40905. /**
  40906. * Clear the info related to rendering groups preventing retention points during dispose.
  40907. */
  40908. freeRenderingGroups(): void;
  40909. /** @hidden */
  40910. _isInIntermediateRendering(): boolean;
  40911. /**
  40912. * Lambda returning the list of potentially active meshes.
  40913. */
  40914. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40915. /**
  40916. * Lambda returning the list of potentially active sub meshes.
  40917. */
  40918. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40919. /**
  40920. * Lambda returning the list of potentially intersecting sub meshes.
  40921. */
  40922. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40923. /**
  40924. * Lambda returning the list of potentially colliding sub meshes.
  40925. */
  40926. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40927. private _activeMeshesFrozen;
  40928. private _skipEvaluateActiveMeshesCompletely;
  40929. /**
  40930. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40931. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40932. * @returns the current scene
  40933. */
  40934. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40935. /**
  40936. * Use this function to restart evaluating active meshes on every frame
  40937. * @returns the current scene
  40938. */
  40939. unfreezeActiveMeshes(): Scene;
  40940. private _evaluateActiveMeshes;
  40941. private _activeMesh;
  40942. /**
  40943. * Update the transform matrix to update from the current active camera
  40944. * @param force defines a boolean used to force the update even if cache is up to date
  40945. */
  40946. updateTransformMatrix(force?: boolean): void;
  40947. private _bindFrameBuffer;
  40948. /** @hidden */
  40949. _allowPostProcessClearColor: boolean;
  40950. /** @hidden */
  40951. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40952. private _processSubCameras;
  40953. private _checkIntersections;
  40954. /** @hidden */
  40955. _advancePhysicsEngineStep(step: number): void;
  40956. /**
  40957. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40958. */
  40959. getDeterministicFrameTime: () => number;
  40960. /** @hidden */
  40961. _animate(): void;
  40962. /** Execute all animations (for a frame) */
  40963. animate(): void;
  40964. /**
  40965. * Render the scene
  40966. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40967. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40968. */
  40969. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40970. /**
  40971. * Freeze all materials
  40972. * A frozen material will not be updatable but should be faster to render
  40973. */
  40974. freezeMaterials(): void;
  40975. /**
  40976. * Unfreeze all materials
  40977. * A frozen material will not be updatable but should be faster to render
  40978. */
  40979. unfreezeMaterials(): void;
  40980. /**
  40981. * Releases all held ressources
  40982. */
  40983. dispose(): void;
  40984. /**
  40985. * Gets if the scene is already disposed
  40986. */
  40987. get isDisposed(): boolean;
  40988. /**
  40989. * Call this function to reduce memory footprint of the scene.
  40990. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40991. */
  40992. clearCachedVertexData(): void;
  40993. /**
  40994. * This function will remove the local cached buffer data from texture.
  40995. * It will save memory but will prevent the texture from being rebuilt
  40996. */
  40997. cleanCachedTextureBuffer(): void;
  40998. /**
  40999. * Get the world extend vectors with an optional filter
  41000. *
  41001. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41002. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41003. */
  41004. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41005. min: Vector3;
  41006. max: Vector3;
  41007. };
  41008. /**
  41009. * Creates a ray that can be used to pick in the scene
  41010. * @param x defines the x coordinate of the origin (on-screen)
  41011. * @param y defines the y coordinate of the origin (on-screen)
  41012. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41013. * @param camera defines the camera to use for the picking
  41014. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41015. * @returns a Ray
  41016. */
  41017. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41018. /**
  41019. * Creates a ray that can be used to pick in the scene
  41020. * @param x defines the x coordinate of the origin (on-screen)
  41021. * @param y defines the y coordinate of the origin (on-screen)
  41022. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41023. * @param result defines the ray where to store the picking ray
  41024. * @param camera defines the camera to use for the picking
  41025. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41026. * @returns the current scene
  41027. */
  41028. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41029. /**
  41030. * Creates a ray that can be used to pick in the scene
  41031. * @param x defines the x coordinate of the origin (on-screen)
  41032. * @param y defines the y coordinate of the origin (on-screen)
  41033. * @param camera defines the camera to use for the picking
  41034. * @returns a Ray
  41035. */
  41036. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41037. /**
  41038. * Creates a ray that can be used to pick in the scene
  41039. * @param x defines the x coordinate of the origin (on-screen)
  41040. * @param y defines the y coordinate of the origin (on-screen)
  41041. * @param result defines the ray where to store the picking ray
  41042. * @param camera defines the camera to use for the picking
  41043. * @returns the current scene
  41044. */
  41045. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41046. /** Launch a ray to try to pick a mesh in the scene
  41047. * @param x position on screen
  41048. * @param y position on screen
  41049. * @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
  41050. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41051. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41053. * @returns a PickingInfo
  41054. */
  41055. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41056. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41057. * @param x position on screen
  41058. * @param y position on screen
  41059. * @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
  41060. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41061. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41062. * @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)
  41063. */
  41064. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41065. /** Use the given ray to pick a mesh in the scene
  41066. * @param ray The ray to use to pick meshes
  41067. * @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
  41068. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41069. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41070. * @returns a PickingInfo
  41071. */
  41072. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41073. /**
  41074. * Launch a ray to try to pick a mesh in the scene
  41075. * @param x X position on screen
  41076. * @param y Y position on screen
  41077. * @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
  41078. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41080. * @returns an array of PickingInfo
  41081. */
  41082. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41083. /**
  41084. * Launch a ray to try to pick a mesh in the scene
  41085. * @param ray Ray to use
  41086. * @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
  41087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41088. * @returns an array of PickingInfo
  41089. */
  41090. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41091. /**
  41092. * Force the value of meshUnderPointer
  41093. * @param mesh defines the mesh to use
  41094. */
  41095. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41096. /**
  41097. * Gets the mesh under the pointer
  41098. * @returns a Mesh or null if no mesh is under the pointer
  41099. */
  41100. getPointerOverMesh(): Nullable<AbstractMesh>;
  41101. /** @hidden */
  41102. _rebuildGeometries(): void;
  41103. /** @hidden */
  41104. _rebuildTextures(): void;
  41105. private _getByTags;
  41106. /**
  41107. * Get a list of meshes by tags
  41108. * @param tagsQuery defines the tags query to use
  41109. * @param forEach defines a predicate used to filter results
  41110. * @returns an array of Mesh
  41111. */
  41112. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41113. /**
  41114. * Get a list of cameras by tags
  41115. * @param tagsQuery defines the tags query to use
  41116. * @param forEach defines a predicate used to filter results
  41117. * @returns an array of Camera
  41118. */
  41119. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41120. /**
  41121. * Get a list of lights by tags
  41122. * @param tagsQuery defines the tags query to use
  41123. * @param forEach defines a predicate used to filter results
  41124. * @returns an array of Light
  41125. */
  41126. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41127. /**
  41128. * Get a list of materials by tags
  41129. * @param tagsQuery defines the tags query to use
  41130. * @param forEach defines a predicate used to filter results
  41131. * @returns an array of Material
  41132. */
  41133. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41134. /**
  41135. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41136. * This allowed control for front to back rendering or reversly depending of the special needs.
  41137. *
  41138. * @param renderingGroupId The rendering group id corresponding to its index
  41139. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41140. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41141. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41142. */
  41143. 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;
  41144. /**
  41145. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41146. *
  41147. * @param renderingGroupId The rendering group id corresponding to its index
  41148. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41149. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41150. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41151. */
  41152. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41153. /**
  41154. * Gets the current auto clear configuration for one rendering group of the rendering
  41155. * manager.
  41156. * @param index the rendering group index to get the information for
  41157. * @returns The auto clear setup for the requested rendering group
  41158. */
  41159. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41160. private _blockMaterialDirtyMechanism;
  41161. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41162. get blockMaterialDirtyMechanism(): boolean;
  41163. set blockMaterialDirtyMechanism(value: boolean);
  41164. /**
  41165. * Will flag all materials as dirty to trigger new shader compilation
  41166. * @param flag defines the flag used to specify which material part must be marked as dirty
  41167. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41168. */
  41169. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41170. /** @hidden */
  41171. _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;
  41172. /** @hidden */
  41173. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41174. /** @hidden */
  41175. _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;
  41176. /** @hidden */
  41177. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41178. /** @hidden */
  41179. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41180. /** @hidden */
  41181. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41182. }
  41183. }
  41184. declare module BABYLON {
  41185. /**
  41186. * Set of assets to keep when moving a scene into an asset container.
  41187. */
  41188. export class KeepAssets extends AbstractScene {
  41189. }
  41190. /**
  41191. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41192. */
  41193. export class InstantiatedEntries {
  41194. /**
  41195. * List of new root nodes (eg. nodes with no parent)
  41196. */
  41197. rootNodes: TransformNode[];
  41198. /**
  41199. * List of new skeletons
  41200. */
  41201. skeletons: Skeleton[];
  41202. /**
  41203. * List of new animation groups
  41204. */
  41205. animationGroups: AnimationGroup[];
  41206. }
  41207. /**
  41208. * Container with a set of assets that can be added or removed from a scene.
  41209. */
  41210. export class AssetContainer extends AbstractScene {
  41211. private _wasAddedToScene;
  41212. /**
  41213. * The scene the AssetContainer belongs to.
  41214. */
  41215. scene: Scene;
  41216. /**
  41217. * Instantiates an AssetContainer.
  41218. * @param scene The scene the AssetContainer belongs to.
  41219. */
  41220. constructor(scene: Scene);
  41221. /**
  41222. * Instantiate or clone all meshes and add the new ones to the scene.
  41223. * Skeletons and animation groups will all be cloned
  41224. * @param nameFunction defines an optional function used to get new names for clones
  41225. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41226. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41227. */
  41228. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41229. /**
  41230. * Adds all the assets from the container to the scene.
  41231. */
  41232. addAllToScene(): void;
  41233. /**
  41234. * Removes all the assets in the container from the scene
  41235. */
  41236. removeAllFromScene(): void;
  41237. /**
  41238. * Disposes all the assets in the container
  41239. */
  41240. dispose(): void;
  41241. private _moveAssets;
  41242. /**
  41243. * Removes all the assets contained in the scene and adds them to the container.
  41244. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41245. */
  41246. moveAllFromScene(keepAssets?: KeepAssets): void;
  41247. /**
  41248. * 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.
  41249. * @returns the root mesh
  41250. */
  41251. createRootMesh(): Mesh;
  41252. /**
  41253. * Merge animations (direct and animation groups) from this asset container into a scene
  41254. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41255. * @param animatables set of animatables to retarget to a node from the scene
  41256. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41257. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41258. */
  41259. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41260. }
  41261. }
  41262. declare module BABYLON {
  41263. /**
  41264. * Defines how the parser contract is defined.
  41265. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41266. */
  41267. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41268. /**
  41269. * Defines how the individual parser contract is defined.
  41270. * These parser can parse an individual asset
  41271. */
  41272. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41273. /**
  41274. * Base class of the scene acting as a container for the different elements composing a scene.
  41275. * This class is dynamically extended by the different components of the scene increasing
  41276. * flexibility and reducing coupling
  41277. */
  41278. export abstract class AbstractScene {
  41279. /**
  41280. * Stores the list of available parsers in the application.
  41281. */
  41282. private static _BabylonFileParsers;
  41283. /**
  41284. * Stores the list of available individual parsers in the application.
  41285. */
  41286. private static _IndividualBabylonFileParsers;
  41287. /**
  41288. * Adds a parser in the list of available ones
  41289. * @param name Defines the name of the parser
  41290. * @param parser Defines the parser to add
  41291. */
  41292. static AddParser(name: string, parser: BabylonFileParser): void;
  41293. /**
  41294. * Gets a general parser from the list of avaialble ones
  41295. * @param name Defines the name of the parser
  41296. * @returns the requested parser or null
  41297. */
  41298. static GetParser(name: string): Nullable<BabylonFileParser>;
  41299. /**
  41300. * Adds n individual parser in the list of available ones
  41301. * @param name Defines the name of the parser
  41302. * @param parser Defines the parser to add
  41303. */
  41304. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41305. /**
  41306. * Gets an individual parser from the list of avaialble ones
  41307. * @param name Defines the name of the parser
  41308. * @returns the requested parser or null
  41309. */
  41310. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41311. /**
  41312. * Parser json data and populate both a scene and its associated container object
  41313. * @param jsonData Defines the data to parse
  41314. * @param scene Defines the scene to parse the data for
  41315. * @param container Defines the container attached to the parsing sequence
  41316. * @param rootUrl Defines the root url of the data
  41317. */
  41318. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41319. /**
  41320. * Gets the list of root nodes (ie. nodes with no parent)
  41321. */
  41322. rootNodes: Node[];
  41323. /** All of the cameras added to this scene
  41324. * @see https://doc.babylonjs.com/babylon101/cameras
  41325. */
  41326. cameras: Camera[];
  41327. /**
  41328. * All of the lights added to this scene
  41329. * @see https://doc.babylonjs.com/babylon101/lights
  41330. */
  41331. lights: Light[];
  41332. /**
  41333. * All of the (abstract) meshes added to this scene
  41334. */
  41335. meshes: AbstractMesh[];
  41336. /**
  41337. * The list of skeletons added to the scene
  41338. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41339. */
  41340. skeletons: Skeleton[];
  41341. /**
  41342. * All of the particle systems added to this scene
  41343. * @see https://doc.babylonjs.com/babylon101/particles
  41344. */
  41345. particleSystems: IParticleSystem[];
  41346. /**
  41347. * Gets a list of Animations associated with the scene
  41348. */
  41349. animations: Animation[];
  41350. /**
  41351. * All of the animation groups added to this scene
  41352. * @see https://doc.babylonjs.com/how_to/group
  41353. */
  41354. animationGroups: AnimationGroup[];
  41355. /**
  41356. * All of the multi-materials added to this scene
  41357. * @see https://doc.babylonjs.com/how_to/multi_materials
  41358. */
  41359. multiMaterials: MultiMaterial[];
  41360. /**
  41361. * All of the materials added to this scene
  41362. * In the context of a Scene, it is not supposed to be modified manually.
  41363. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41364. * Note also that the order of the Material within the array is not significant and might change.
  41365. * @see https://doc.babylonjs.com/babylon101/materials
  41366. */
  41367. materials: Material[];
  41368. /**
  41369. * The list of morph target managers added to the scene
  41370. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41371. */
  41372. morphTargetManagers: MorphTargetManager[];
  41373. /**
  41374. * The list of geometries used in the scene.
  41375. */
  41376. geometries: Geometry[];
  41377. /**
  41378. * All of the tranform nodes added to this scene
  41379. * In the context of a Scene, it is not supposed to be modified manually.
  41380. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41381. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41382. * @see https://doc.babylonjs.com/how_to/transformnode
  41383. */
  41384. transformNodes: TransformNode[];
  41385. /**
  41386. * ActionManagers available on the scene.
  41387. */
  41388. actionManagers: AbstractActionManager[];
  41389. /**
  41390. * Textures to keep.
  41391. */
  41392. textures: BaseTexture[];
  41393. /**
  41394. * Environment texture for the scene
  41395. */
  41396. environmentTexture: Nullable<BaseTexture>;
  41397. /**
  41398. * The list of postprocesses added to the scene
  41399. */
  41400. postProcesses: PostProcess[];
  41401. /**
  41402. * @returns all meshes, lights, cameras, transformNodes and bones
  41403. */
  41404. getNodes(): Array<Node>;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. /**
  41409. * Interface used to define options for Sound class
  41410. */
  41411. export interface ISoundOptions {
  41412. /**
  41413. * Does the sound autoplay once loaded.
  41414. */
  41415. autoplay?: boolean;
  41416. /**
  41417. * Does the sound loop after it finishes playing once.
  41418. */
  41419. loop?: boolean;
  41420. /**
  41421. * Sound's volume
  41422. */
  41423. volume?: number;
  41424. /**
  41425. * Is it a spatial sound?
  41426. */
  41427. spatialSound?: boolean;
  41428. /**
  41429. * Maximum distance to hear that sound
  41430. */
  41431. maxDistance?: number;
  41432. /**
  41433. * Uses user defined attenuation function
  41434. */
  41435. useCustomAttenuation?: boolean;
  41436. /**
  41437. * Define the roll off factor of spatial sounds.
  41438. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41439. */
  41440. rolloffFactor?: number;
  41441. /**
  41442. * Define the reference distance the sound should be heard perfectly.
  41443. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41444. */
  41445. refDistance?: number;
  41446. /**
  41447. * Define the distance attenuation model the sound will follow.
  41448. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41449. */
  41450. distanceModel?: string;
  41451. /**
  41452. * Defines the playback speed (1 by default)
  41453. */
  41454. playbackRate?: number;
  41455. /**
  41456. * Defines if the sound is from a streaming source
  41457. */
  41458. streaming?: boolean;
  41459. /**
  41460. * Defines an optional length (in seconds) inside the sound file
  41461. */
  41462. length?: number;
  41463. /**
  41464. * Defines an optional offset (in seconds) inside the sound file
  41465. */
  41466. offset?: number;
  41467. /**
  41468. * If true, URLs will not be required to state the audio file codec to use.
  41469. */
  41470. skipCodecCheck?: boolean;
  41471. }
  41472. /**
  41473. * Defines a sound that can be played in the application.
  41474. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41475. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41476. */
  41477. export class Sound {
  41478. /**
  41479. * The name of the sound in the scene.
  41480. */
  41481. name: string;
  41482. /**
  41483. * Does the sound autoplay once loaded.
  41484. */
  41485. autoplay: boolean;
  41486. /**
  41487. * Does the sound loop after it finishes playing once.
  41488. */
  41489. loop: boolean;
  41490. /**
  41491. * Does the sound use a custom attenuation curve to simulate the falloff
  41492. * happening when the source gets further away from the camera.
  41493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41494. */
  41495. useCustomAttenuation: boolean;
  41496. /**
  41497. * The sound track id this sound belongs to.
  41498. */
  41499. soundTrackId: number;
  41500. /**
  41501. * Is this sound currently played.
  41502. */
  41503. isPlaying: boolean;
  41504. /**
  41505. * Is this sound currently paused.
  41506. */
  41507. isPaused: boolean;
  41508. /**
  41509. * Does this sound enables spatial sound.
  41510. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41511. */
  41512. spatialSound: boolean;
  41513. /**
  41514. * Define the reference distance the sound should be heard perfectly.
  41515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41516. */
  41517. refDistance: number;
  41518. /**
  41519. * Define the roll off factor of spatial sounds.
  41520. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41521. */
  41522. rolloffFactor: number;
  41523. /**
  41524. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41525. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41526. */
  41527. maxDistance: number;
  41528. /**
  41529. * Define the distance attenuation model the sound will follow.
  41530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41531. */
  41532. distanceModel: string;
  41533. /**
  41534. * @hidden
  41535. * Back Compat
  41536. **/
  41537. onended: () => any;
  41538. /**
  41539. * Gets or sets an object used to store user defined information for the sound.
  41540. */
  41541. metadata: any;
  41542. /**
  41543. * Observable event when the current playing sound finishes.
  41544. */
  41545. onEndedObservable: Observable<Sound>;
  41546. private _panningModel;
  41547. private _playbackRate;
  41548. private _streaming;
  41549. private _startTime;
  41550. private _startOffset;
  41551. private _position;
  41552. /** @hidden */
  41553. _positionInEmitterSpace: boolean;
  41554. private _localDirection;
  41555. private _volume;
  41556. private _isReadyToPlay;
  41557. private _isDirectional;
  41558. private _readyToPlayCallback;
  41559. private _audioBuffer;
  41560. private _soundSource;
  41561. private _streamingSource;
  41562. private _soundPanner;
  41563. private _soundGain;
  41564. private _inputAudioNode;
  41565. private _outputAudioNode;
  41566. private _coneInnerAngle;
  41567. private _coneOuterAngle;
  41568. private _coneOuterGain;
  41569. private _scene;
  41570. private _connectedTransformNode;
  41571. private _customAttenuationFunction;
  41572. private _registerFunc;
  41573. private _isOutputConnected;
  41574. private _htmlAudioElement;
  41575. private _urlType;
  41576. private _length?;
  41577. private _offset?;
  41578. /** @hidden */
  41579. static _SceneComponentInitialization: (scene: Scene) => void;
  41580. /**
  41581. * Create a sound and attach it to a scene
  41582. * @param name Name of your sound
  41583. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41584. * @param scene defines the scene the sound belongs to
  41585. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41586. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41587. */
  41588. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41589. /**
  41590. * Release the sound and its associated resources
  41591. */
  41592. dispose(): void;
  41593. /**
  41594. * Gets if the sounds is ready to be played or not.
  41595. * @returns true if ready, otherwise false
  41596. */
  41597. isReady(): boolean;
  41598. private _soundLoaded;
  41599. /**
  41600. * Sets the data of the sound from an audiobuffer
  41601. * @param audioBuffer The audioBuffer containing the data
  41602. */
  41603. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41604. /**
  41605. * Updates the current sounds options such as maxdistance, loop...
  41606. * @param options A JSON object containing values named as the object properties
  41607. */
  41608. updateOptions(options: ISoundOptions): void;
  41609. private _createSpatialParameters;
  41610. private _updateSpatialParameters;
  41611. /**
  41612. * Switch the panning model to HRTF:
  41613. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41615. */
  41616. switchPanningModelToHRTF(): void;
  41617. /**
  41618. * Switch the panning model to Equal Power:
  41619. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41620. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41621. */
  41622. switchPanningModelToEqualPower(): void;
  41623. private _switchPanningModel;
  41624. /**
  41625. * Connect this sound to a sound track audio node like gain...
  41626. * @param soundTrackAudioNode the sound track audio node to connect to
  41627. */
  41628. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41629. /**
  41630. * Transform this sound into a directional source
  41631. * @param coneInnerAngle Size of the inner cone in degree
  41632. * @param coneOuterAngle Size of the outer cone in degree
  41633. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41634. */
  41635. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41636. /**
  41637. * Gets or sets the inner angle for the directional cone.
  41638. */
  41639. get directionalConeInnerAngle(): number;
  41640. /**
  41641. * Gets or sets the inner angle for the directional cone.
  41642. */
  41643. set directionalConeInnerAngle(value: number);
  41644. /**
  41645. * Gets or sets the outer angle for the directional cone.
  41646. */
  41647. get directionalConeOuterAngle(): number;
  41648. /**
  41649. * Gets or sets the outer angle for the directional cone.
  41650. */
  41651. set directionalConeOuterAngle(value: number);
  41652. /**
  41653. * Sets the position of the emitter if spatial sound is enabled
  41654. * @param newPosition Defines the new posisiton
  41655. */
  41656. setPosition(newPosition: Vector3): void;
  41657. /**
  41658. * Sets the local direction of the emitter if spatial sound is enabled
  41659. * @param newLocalDirection Defines the new local direction
  41660. */
  41661. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41662. private _updateDirection;
  41663. /** @hidden */
  41664. updateDistanceFromListener(): void;
  41665. /**
  41666. * Sets a new custom attenuation function for the sound.
  41667. * @param callback Defines the function used for the attenuation
  41668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41669. */
  41670. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41671. /**
  41672. * Play the sound
  41673. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41674. * @param offset (optional) Start the sound at a specific time in seconds
  41675. * @param length (optional) Sound duration (in seconds)
  41676. */
  41677. play(time?: number, offset?: number, length?: number): void;
  41678. private _onended;
  41679. /**
  41680. * Stop the sound
  41681. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41682. */
  41683. stop(time?: number): void;
  41684. /**
  41685. * Put the sound in pause
  41686. */
  41687. pause(): void;
  41688. /**
  41689. * Sets a dedicated volume for this sounds
  41690. * @param newVolume Define the new volume of the sound
  41691. * @param time Define time for gradual change to new volume
  41692. */
  41693. setVolume(newVolume: number, time?: number): void;
  41694. /**
  41695. * Set the sound play back rate
  41696. * @param newPlaybackRate Define the playback rate the sound should be played at
  41697. */
  41698. setPlaybackRate(newPlaybackRate: number): void;
  41699. /**
  41700. * Gets the volume of the sound.
  41701. * @returns the volume of the sound
  41702. */
  41703. getVolume(): number;
  41704. /**
  41705. * Attach the sound to a dedicated mesh
  41706. * @param transformNode The transform node to connect the sound with
  41707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41708. */
  41709. attachToMesh(transformNode: TransformNode): void;
  41710. /**
  41711. * Detach the sound from the previously attached mesh
  41712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41713. */
  41714. detachFromMesh(): void;
  41715. private _onRegisterAfterWorldMatrixUpdate;
  41716. /**
  41717. * Clone the current sound in the scene.
  41718. * @returns the new sound clone
  41719. */
  41720. clone(): Nullable<Sound>;
  41721. /**
  41722. * Gets the current underlying audio buffer containing the data
  41723. * @returns the audio buffer
  41724. */
  41725. getAudioBuffer(): Nullable<AudioBuffer>;
  41726. /**
  41727. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41728. * @returns the source node
  41729. */
  41730. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41731. /**
  41732. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41733. * @returns the gain node
  41734. */
  41735. getSoundGain(): Nullable<GainNode>;
  41736. /**
  41737. * Serializes the Sound in a JSON representation
  41738. * @returns the JSON representation of the sound
  41739. */
  41740. serialize(): any;
  41741. /**
  41742. * Parse a JSON representation of a sound to innstantiate in a given scene
  41743. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41744. * @param scene Define the scene the new parsed sound should be created in
  41745. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41746. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41747. * @returns the newly parsed sound
  41748. */
  41749. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41750. }
  41751. }
  41752. declare module BABYLON {
  41753. /**
  41754. * This defines an action helpful to play a defined sound on a triggered action.
  41755. */
  41756. export class PlaySoundAction extends Action {
  41757. private _sound;
  41758. /**
  41759. * Instantiate the action
  41760. * @param triggerOptions defines the trigger options
  41761. * @param sound defines the sound to play
  41762. * @param condition defines the trigger related conditions
  41763. */
  41764. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41765. /** @hidden */
  41766. _prepare(): void;
  41767. /**
  41768. * Execute the action and play the sound.
  41769. */
  41770. execute(): void;
  41771. /**
  41772. * Serializes the actions and its related information.
  41773. * @param parent defines the object to serialize in
  41774. * @returns the serialized object
  41775. */
  41776. serialize(parent: any): any;
  41777. }
  41778. /**
  41779. * This defines an action helpful to stop a defined sound on a triggered action.
  41780. */
  41781. export class StopSoundAction extends Action {
  41782. private _sound;
  41783. /**
  41784. * Instantiate the action
  41785. * @param triggerOptions defines the trigger options
  41786. * @param sound defines the sound to stop
  41787. * @param condition defines the trigger related conditions
  41788. */
  41789. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41790. /** @hidden */
  41791. _prepare(): void;
  41792. /**
  41793. * Execute the action and stop the sound.
  41794. */
  41795. execute(): void;
  41796. /**
  41797. * Serializes the actions and its related information.
  41798. * @param parent defines the object to serialize in
  41799. * @returns the serialized object
  41800. */
  41801. serialize(parent: any): any;
  41802. }
  41803. }
  41804. declare module BABYLON {
  41805. /**
  41806. * This defines an action responsible to change the value of a property
  41807. * by interpolating between its current value and the newly set one once triggered.
  41808. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41809. */
  41810. export class InterpolateValueAction extends Action {
  41811. /**
  41812. * Defines the path of the property where the value should be interpolated
  41813. */
  41814. propertyPath: string;
  41815. /**
  41816. * Defines the target value at the end of the interpolation.
  41817. */
  41818. value: any;
  41819. /**
  41820. * Defines the time it will take for the property to interpolate to the value.
  41821. */
  41822. duration: number;
  41823. /**
  41824. * Defines if the other scene animations should be stopped when the action has been triggered
  41825. */
  41826. stopOtherAnimations?: boolean;
  41827. /**
  41828. * Defines a callback raised once the interpolation animation has been done.
  41829. */
  41830. onInterpolationDone?: () => void;
  41831. /**
  41832. * Observable triggered once the interpolation animation has been done.
  41833. */
  41834. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41835. private _target;
  41836. private _effectiveTarget;
  41837. private _property;
  41838. /**
  41839. * Instantiate the action
  41840. * @param triggerOptions defines the trigger options
  41841. * @param target defines the object containing the value to interpolate
  41842. * @param propertyPath defines the path to the property in the target object
  41843. * @param value defines the target value at the end of the interpolation
  41844. * @param duration deines the time it will take for the property to interpolate to the value.
  41845. * @param condition defines the trigger related conditions
  41846. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41847. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41848. */
  41849. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41850. /** @hidden */
  41851. _prepare(): void;
  41852. /**
  41853. * Execute the action starts the value interpolation.
  41854. */
  41855. execute(): void;
  41856. /**
  41857. * Serializes the actions and its related information.
  41858. * @param parent defines the object to serialize in
  41859. * @returns the serialized object
  41860. */
  41861. serialize(parent: any): any;
  41862. }
  41863. }
  41864. declare module BABYLON {
  41865. /**
  41866. * Options allowed during the creation of a sound track.
  41867. */
  41868. export interface ISoundTrackOptions {
  41869. /**
  41870. * The volume the sound track should take during creation
  41871. */
  41872. volume?: number;
  41873. /**
  41874. * Define if the sound track is the main sound track of the scene
  41875. */
  41876. mainTrack?: boolean;
  41877. }
  41878. /**
  41879. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41880. * It will be also used in a future release to apply effects on a specific track.
  41881. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41882. */
  41883. export class SoundTrack {
  41884. /**
  41885. * The unique identifier of the sound track in the scene.
  41886. */
  41887. id: number;
  41888. /**
  41889. * The list of sounds included in the sound track.
  41890. */
  41891. soundCollection: Array<Sound>;
  41892. private _outputAudioNode;
  41893. private _scene;
  41894. private _connectedAnalyser;
  41895. private _options;
  41896. private _isInitialized;
  41897. /**
  41898. * Creates a new sound track.
  41899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41900. * @param scene Define the scene the sound track belongs to
  41901. * @param options
  41902. */
  41903. constructor(scene: Scene, options?: ISoundTrackOptions);
  41904. private _initializeSoundTrackAudioGraph;
  41905. /**
  41906. * Release the sound track and its associated resources
  41907. */
  41908. dispose(): void;
  41909. /**
  41910. * Adds a sound to this sound track
  41911. * @param sound define the cound to add
  41912. * @ignoreNaming
  41913. */
  41914. AddSound(sound: Sound): void;
  41915. /**
  41916. * Removes a sound to this sound track
  41917. * @param sound define the cound to remove
  41918. * @ignoreNaming
  41919. */
  41920. RemoveSound(sound: Sound): void;
  41921. /**
  41922. * Set a global volume for the full sound track.
  41923. * @param newVolume Define the new volume of the sound track
  41924. */
  41925. setVolume(newVolume: number): void;
  41926. /**
  41927. * Switch the panning model to HRTF:
  41928. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41930. */
  41931. switchPanningModelToHRTF(): void;
  41932. /**
  41933. * Switch the panning model to Equal Power:
  41934. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41935. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41936. */
  41937. switchPanningModelToEqualPower(): void;
  41938. /**
  41939. * Connect the sound track to an audio analyser allowing some amazing
  41940. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41941. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41942. * @param analyser The analyser to connect to the engine
  41943. */
  41944. connectToAnalyser(analyser: Analyser): void;
  41945. }
  41946. }
  41947. declare module BABYLON {
  41948. interface AbstractScene {
  41949. /**
  41950. * The list of sounds used in the scene.
  41951. */
  41952. sounds: Nullable<Array<Sound>>;
  41953. }
  41954. interface Scene {
  41955. /**
  41956. * @hidden
  41957. * Backing field
  41958. */
  41959. _mainSoundTrack: SoundTrack;
  41960. /**
  41961. * The main sound track played by the scene.
  41962. * It cotains your primary collection of sounds.
  41963. */
  41964. mainSoundTrack: SoundTrack;
  41965. /**
  41966. * The list of sound tracks added to the scene
  41967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41968. */
  41969. soundTracks: Nullable<Array<SoundTrack>>;
  41970. /**
  41971. * Gets a sound using a given name
  41972. * @param name defines the name to search for
  41973. * @return the found sound or null if not found at all.
  41974. */
  41975. getSoundByName(name: string): Nullable<Sound>;
  41976. /**
  41977. * Gets or sets if audio support is enabled
  41978. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41979. */
  41980. audioEnabled: boolean;
  41981. /**
  41982. * Gets or sets if audio will be output to headphones
  41983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41984. */
  41985. headphone: boolean;
  41986. /**
  41987. * Gets or sets custom audio listener position provider
  41988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41989. */
  41990. audioListenerPositionProvider: Nullable<() => Vector3>;
  41991. /**
  41992. * Gets or sets a refresh rate when using 3D audio positioning
  41993. */
  41994. audioPositioningRefreshRate: number;
  41995. }
  41996. /**
  41997. * Defines the sound scene component responsible to manage any sounds
  41998. * in a given scene.
  41999. */
  42000. export class AudioSceneComponent implements ISceneSerializableComponent {
  42001. /**
  42002. * The component name helpfull to identify the component in the list of scene components.
  42003. */
  42004. readonly name: string;
  42005. /**
  42006. * The scene the component belongs to.
  42007. */
  42008. scene: Scene;
  42009. private _audioEnabled;
  42010. /**
  42011. * Gets whether audio is enabled or not.
  42012. * Please use related enable/disable method to switch state.
  42013. */
  42014. get audioEnabled(): boolean;
  42015. private _headphone;
  42016. /**
  42017. * Gets whether audio is outputing to headphone or not.
  42018. * Please use the according Switch methods to change output.
  42019. */
  42020. get headphone(): boolean;
  42021. /**
  42022. * Gets or sets a refresh rate when using 3D audio positioning
  42023. */
  42024. audioPositioningRefreshRate: number;
  42025. private _audioListenerPositionProvider;
  42026. /**
  42027. * Gets the current audio listener position provider
  42028. */
  42029. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42030. /**
  42031. * Sets a custom listener position for all sounds in the scene
  42032. * By default, this is the position of the first active camera
  42033. */
  42034. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42035. /**
  42036. * Creates a new instance of the component for the given scene
  42037. * @param scene Defines the scene to register the component in
  42038. */
  42039. constructor(scene: Scene);
  42040. /**
  42041. * Registers the component in a given scene
  42042. */
  42043. register(): void;
  42044. /**
  42045. * Rebuilds the elements related to this component in case of
  42046. * context lost for instance.
  42047. */
  42048. rebuild(): void;
  42049. /**
  42050. * Serializes the component data to the specified json object
  42051. * @param serializationObject The object to serialize to
  42052. */
  42053. serialize(serializationObject: any): void;
  42054. /**
  42055. * Adds all the elements from the container to the scene
  42056. * @param container the container holding the elements
  42057. */
  42058. addFromContainer(container: AbstractScene): void;
  42059. /**
  42060. * Removes all the elements in the container from the scene
  42061. * @param container contains the elements to remove
  42062. * @param dispose if the removed element should be disposed (default: false)
  42063. */
  42064. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42065. /**
  42066. * Disposes the component and the associated ressources.
  42067. */
  42068. dispose(): void;
  42069. /**
  42070. * Disables audio in the associated scene.
  42071. */
  42072. disableAudio(): void;
  42073. /**
  42074. * Enables audio in the associated scene.
  42075. */
  42076. enableAudio(): void;
  42077. /**
  42078. * Switch audio to headphone output.
  42079. */
  42080. switchAudioModeForHeadphones(): void;
  42081. /**
  42082. * Switch audio to normal speakers.
  42083. */
  42084. switchAudioModeForNormalSpeakers(): void;
  42085. private _cachedCameraDirection;
  42086. private _cachedCameraPosition;
  42087. private _lastCheck;
  42088. private _afterRender;
  42089. }
  42090. }
  42091. declare module BABYLON {
  42092. /**
  42093. * Wraps one or more Sound objects and selects one with random weight for playback.
  42094. */
  42095. export class WeightedSound {
  42096. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42097. loop: boolean;
  42098. private _coneInnerAngle;
  42099. private _coneOuterAngle;
  42100. private _volume;
  42101. /** A Sound is currently playing. */
  42102. isPlaying: boolean;
  42103. /** A Sound is currently paused. */
  42104. isPaused: boolean;
  42105. private _sounds;
  42106. private _weights;
  42107. private _currentIndex?;
  42108. /**
  42109. * Creates a new WeightedSound from the list of sounds given.
  42110. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42111. * @param sounds Array of Sounds that will be selected from.
  42112. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42113. */
  42114. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42115. /**
  42116. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42117. */
  42118. get directionalConeInnerAngle(): number;
  42119. /**
  42120. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42121. */
  42122. set directionalConeInnerAngle(value: number);
  42123. /**
  42124. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42125. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42126. */
  42127. get directionalConeOuterAngle(): number;
  42128. /**
  42129. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42130. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42131. */
  42132. set directionalConeOuterAngle(value: number);
  42133. /**
  42134. * Playback volume.
  42135. */
  42136. get volume(): number;
  42137. /**
  42138. * Playback volume.
  42139. */
  42140. set volume(value: number);
  42141. private _onended;
  42142. /**
  42143. * Suspend playback
  42144. */
  42145. pause(): void;
  42146. /**
  42147. * Stop playback
  42148. */
  42149. stop(): void;
  42150. /**
  42151. * Start playback.
  42152. * @param startOffset Position the clip head at a specific time in seconds.
  42153. */
  42154. play(startOffset?: number): void;
  42155. }
  42156. }
  42157. declare module BABYLON {
  42158. /**
  42159. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42160. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42161. */
  42162. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42163. /**
  42164. * Gets the name of the behavior.
  42165. */
  42166. get name(): string;
  42167. /**
  42168. * The easing function used by animations
  42169. */
  42170. static EasingFunction: BackEase;
  42171. /**
  42172. * The easing mode used by animations
  42173. */
  42174. static EasingMode: number;
  42175. /**
  42176. * The duration of the animation, in milliseconds
  42177. */
  42178. transitionDuration: number;
  42179. /**
  42180. * Length of the distance animated by the transition when lower radius is reached
  42181. */
  42182. lowerRadiusTransitionRange: number;
  42183. /**
  42184. * Length of the distance animated by the transition when upper radius is reached
  42185. */
  42186. upperRadiusTransitionRange: number;
  42187. private _autoTransitionRange;
  42188. /**
  42189. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42190. */
  42191. get autoTransitionRange(): boolean;
  42192. /**
  42193. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42194. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42195. */
  42196. set autoTransitionRange(value: boolean);
  42197. private _attachedCamera;
  42198. private _onAfterCheckInputsObserver;
  42199. private _onMeshTargetChangedObserver;
  42200. /**
  42201. * Initializes the behavior.
  42202. */
  42203. init(): void;
  42204. /**
  42205. * Attaches the behavior to its arc rotate camera.
  42206. * @param camera Defines the camera to attach the behavior to
  42207. */
  42208. attach(camera: ArcRotateCamera): void;
  42209. /**
  42210. * Detaches the behavior from its current arc rotate camera.
  42211. */
  42212. detach(): void;
  42213. private _radiusIsAnimating;
  42214. private _radiusBounceTransition;
  42215. private _animatables;
  42216. private _cachedWheelPrecision;
  42217. /**
  42218. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42219. * @param radiusLimit The limit to check against.
  42220. * @return Bool to indicate if at limit.
  42221. */
  42222. private _isRadiusAtLimit;
  42223. /**
  42224. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42225. * @param radiusDelta The delta by which to animate to. Can be negative.
  42226. */
  42227. private _applyBoundRadiusAnimation;
  42228. /**
  42229. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42230. */
  42231. protected _clearAnimationLocks(): void;
  42232. /**
  42233. * Stops and removes all animations that have been applied to the camera
  42234. */
  42235. stopAllAnimations(): void;
  42236. }
  42237. }
  42238. declare module BABYLON {
  42239. /**
  42240. * 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.
  42241. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42242. */
  42243. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42244. /**
  42245. * Gets the name of the behavior.
  42246. */
  42247. get name(): string;
  42248. private _mode;
  42249. private _radiusScale;
  42250. private _positionScale;
  42251. private _defaultElevation;
  42252. private _elevationReturnTime;
  42253. private _elevationReturnWaitTime;
  42254. private _zoomStopsAnimation;
  42255. private _framingTime;
  42256. /**
  42257. * The easing function used by animations
  42258. */
  42259. static EasingFunction: ExponentialEase;
  42260. /**
  42261. * The easing mode used by animations
  42262. */
  42263. static EasingMode: number;
  42264. /**
  42265. * Sets the current mode used by the behavior
  42266. */
  42267. set mode(mode: number);
  42268. /**
  42269. * Gets current mode used by the behavior.
  42270. */
  42271. get mode(): number;
  42272. /**
  42273. * Sets the scale applied to the radius (1 by default)
  42274. */
  42275. set radiusScale(radius: number);
  42276. /**
  42277. * Gets the scale applied to the radius
  42278. */
  42279. get radiusScale(): number;
  42280. /**
  42281. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42282. */
  42283. set positionScale(scale: number);
  42284. /**
  42285. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42286. */
  42287. get positionScale(): number;
  42288. /**
  42289. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42290. * behaviour is triggered, in radians.
  42291. */
  42292. set defaultElevation(elevation: number);
  42293. /**
  42294. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42295. * behaviour is triggered, in radians.
  42296. */
  42297. get defaultElevation(): number;
  42298. /**
  42299. * Sets the time (in milliseconds) taken to return to the default beta position.
  42300. * Negative value indicates camera should not return to default.
  42301. */
  42302. set elevationReturnTime(speed: number);
  42303. /**
  42304. * Gets the time (in milliseconds) taken to return to the default beta position.
  42305. * Negative value indicates camera should not return to default.
  42306. */
  42307. get elevationReturnTime(): number;
  42308. /**
  42309. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42310. */
  42311. set elevationReturnWaitTime(time: number);
  42312. /**
  42313. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42314. */
  42315. get elevationReturnWaitTime(): number;
  42316. /**
  42317. * Sets the flag that indicates if user zooming should stop animation.
  42318. */
  42319. set zoomStopsAnimation(flag: boolean);
  42320. /**
  42321. * Gets the flag that indicates if user zooming should stop animation.
  42322. */
  42323. get zoomStopsAnimation(): boolean;
  42324. /**
  42325. * Sets the transition time when framing the mesh, in milliseconds
  42326. */
  42327. set framingTime(time: number);
  42328. /**
  42329. * Gets the transition time when framing the mesh, in milliseconds
  42330. */
  42331. get framingTime(): number;
  42332. /**
  42333. * Define if the behavior should automatically change the configured
  42334. * camera limits and sensibilities.
  42335. */
  42336. autoCorrectCameraLimitsAndSensibility: boolean;
  42337. private _onPrePointerObservableObserver;
  42338. private _onAfterCheckInputsObserver;
  42339. private _onMeshTargetChangedObserver;
  42340. private _attachedCamera;
  42341. private _isPointerDown;
  42342. private _lastInteractionTime;
  42343. /**
  42344. * Initializes the behavior.
  42345. */
  42346. init(): void;
  42347. /**
  42348. * Attaches the behavior to its arc rotate camera.
  42349. * @param camera Defines the camera to attach the behavior to
  42350. */
  42351. attach(camera: ArcRotateCamera): void;
  42352. /**
  42353. * Detaches the behavior from its current arc rotate camera.
  42354. */
  42355. detach(): void;
  42356. private _animatables;
  42357. private _betaIsAnimating;
  42358. private _betaTransition;
  42359. private _radiusTransition;
  42360. private _vectorTransition;
  42361. /**
  42362. * Targets the given mesh and updates zoom level accordingly.
  42363. * @param mesh The mesh to target.
  42364. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42365. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42366. */
  42367. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42368. /**
  42369. * Targets the given mesh with its children and updates zoom level accordingly.
  42370. * @param mesh The mesh to target.
  42371. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42372. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42373. */
  42374. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42375. /**
  42376. * Targets the given meshes with their children and updates zoom level accordingly.
  42377. * @param meshes The mesh to target.
  42378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42380. */
  42381. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42382. /**
  42383. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42384. * @param minimumWorld Determines the smaller position of the bounding box extend
  42385. * @param maximumWorld Determines the bigger position of the bounding box extend
  42386. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42387. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42388. */
  42389. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42390. /**
  42391. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42392. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42393. * frustum width.
  42394. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42395. * to fully enclose the mesh in the viewing frustum.
  42396. */
  42397. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42398. /**
  42399. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42400. * is automatically returned to its default position (expected to be above ground plane).
  42401. */
  42402. private _maintainCameraAboveGround;
  42403. /**
  42404. * Returns the frustum slope based on the canvas ratio and camera FOV
  42405. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42406. */
  42407. private _getFrustumSlope;
  42408. /**
  42409. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42410. */
  42411. private _clearAnimationLocks;
  42412. /**
  42413. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42414. */
  42415. private _applyUserInteraction;
  42416. /**
  42417. * Stops and removes all animations that have been applied to the camera
  42418. */
  42419. stopAllAnimations(): void;
  42420. /**
  42421. * Gets a value indicating if the user is moving the camera
  42422. */
  42423. get isUserIsMoving(): boolean;
  42424. /**
  42425. * The camera can move all the way towards the mesh.
  42426. */
  42427. static IgnoreBoundsSizeMode: number;
  42428. /**
  42429. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42430. */
  42431. static FitFrustumSidesMode: number;
  42432. }
  42433. }
  42434. declare module BABYLON {
  42435. /**
  42436. * Base class for Camera Pointer Inputs.
  42437. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42438. * for example usage.
  42439. */
  42440. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42441. /**
  42442. * Defines the camera the input is attached to.
  42443. */
  42444. abstract camera: Camera;
  42445. /**
  42446. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42447. */
  42448. protected _altKey: boolean;
  42449. protected _ctrlKey: boolean;
  42450. protected _metaKey: boolean;
  42451. protected _shiftKey: boolean;
  42452. /**
  42453. * Which mouse buttons were pressed at time of last mouse event.
  42454. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42455. */
  42456. protected _buttonsPressed: number;
  42457. /**
  42458. * Defines the buttons associated with the input to handle camera move.
  42459. */
  42460. buttons: number[];
  42461. /**
  42462. * Attach the input controls to a specific dom element to get the input from.
  42463. * @param element Defines the element the controls should be listened from
  42464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42465. */
  42466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42467. /**
  42468. * Detach the current controls from the specified dom element.
  42469. * @param element Defines the element to stop listening the inputs from
  42470. */
  42471. detachControl(element: Nullable<HTMLElement>): void;
  42472. /**
  42473. * Gets the class name of the current input.
  42474. * @returns the class name
  42475. */
  42476. getClassName(): string;
  42477. /**
  42478. * Get the friendly name associated with the input class.
  42479. * @returns the input friendly name
  42480. */
  42481. getSimpleName(): string;
  42482. /**
  42483. * Called on pointer POINTERDOUBLETAP event.
  42484. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42485. */
  42486. protected onDoubleTap(type: string): void;
  42487. /**
  42488. * Called on pointer POINTERMOVE event if only a single touch is active.
  42489. * Override this method to provide functionality.
  42490. */
  42491. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42492. /**
  42493. * Called on pointer POINTERMOVE event if multiple touches are active.
  42494. * Override this method to provide functionality.
  42495. */
  42496. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42497. /**
  42498. * Called on JS contextmenu event.
  42499. * Override this method to provide functionality.
  42500. */
  42501. protected onContextMenu(evt: PointerEvent): void;
  42502. /**
  42503. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42504. * press.
  42505. * Override this method to provide functionality.
  42506. */
  42507. protected onButtonDown(evt: PointerEvent): void;
  42508. /**
  42509. * Called each time a new POINTERUP event occurs. Ie, for each button
  42510. * release.
  42511. * Override this method to provide functionality.
  42512. */
  42513. protected onButtonUp(evt: PointerEvent): void;
  42514. /**
  42515. * Called when window becomes inactive.
  42516. * Override this method to provide functionality.
  42517. */
  42518. protected onLostFocus(): void;
  42519. private _pointerInput;
  42520. private _observer;
  42521. private _onLostFocus;
  42522. private pointA;
  42523. private pointB;
  42524. }
  42525. }
  42526. declare module BABYLON {
  42527. /**
  42528. * Manage the pointers inputs to control an arc rotate camera.
  42529. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42530. */
  42531. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42532. /**
  42533. * Defines the camera the input is attached to.
  42534. */
  42535. camera: ArcRotateCamera;
  42536. /**
  42537. * Gets the class name of the current input.
  42538. * @returns the class name
  42539. */
  42540. getClassName(): string;
  42541. /**
  42542. * Defines the buttons associated with the input to handle camera move.
  42543. */
  42544. buttons: number[];
  42545. /**
  42546. * Defines the pointer angular sensibility along the X axis or how fast is
  42547. * the camera rotating.
  42548. */
  42549. angularSensibilityX: number;
  42550. /**
  42551. * Defines the pointer angular sensibility along the Y axis or how fast is
  42552. * the camera rotating.
  42553. */
  42554. angularSensibilityY: number;
  42555. /**
  42556. * Defines the pointer pinch precision or how fast is the camera zooming.
  42557. */
  42558. pinchPrecision: number;
  42559. /**
  42560. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42561. * from 0.
  42562. * It defines the percentage of current camera.radius to use as delta when
  42563. * pinch zoom is used.
  42564. */
  42565. pinchDeltaPercentage: number;
  42566. /**
  42567. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42568. * that any object in the plane at the camera's target point will scale
  42569. * perfectly with finger motion.
  42570. * Overrides pinchDeltaPercentage and pinchPrecision.
  42571. */
  42572. useNaturalPinchZoom: boolean;
  42573. /**
  42574. * Defines the pointer panning sensibility or how fast is the camera moving.
  42575. */
  42576. panningSensibility: number;
  42577. /**
  42578. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42579. */
  42580. multiTouchPanning: boolean;
  42581. /**
  42582. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42583. * zoom (pinch) through multitouch.
  42584. */
  42585. multiTouchPanAndZoom: boolean;
  42586. /**
  42587. * Revers pinch action direction.
  42588. */
  42589. pinchInwards: boolean;
  42590. private _isPanClick;
  42591. private _twoFingerActivityCount;
  42592. private _isPinching;
  42593. /**
  42594. * Called on pointer POINTERMOVE event if only a single touch is active.
  42595. */
  42596. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42597. /**
  42598. * Called on pointer POINTERDOUBLETAP event.
  42599. */
  42600. protected onDoubleTap(type: string): void;
  42601. /**
  42602. * Called on pointer POINTERMOVE event if multiple touches are active.
  42603. */
  42604. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42605. /**
  42606. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42607. * press.
  42608. */
  42609. protected onButtonDown(evt: PointerEvent): void;
  42610. /**
  42611. * Called each time a new POINTERUP event occurs. Ie, for each button
  42612. * release.
  42613. */
  42614. protected onButtonUp(evt: PointerEvent): void;
  42615. /**
  42616. * Called when window becomes inactive.
  42617. */
  42618. protected onLostFocus(): void;
  42619. }
  42620. }
  42621. declare module BABYLON {
  42622. /**
  42623. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42624. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42625. */
  42626. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42627. /**
  42628. * Defines the camera the input is attached to.
  42629. */
  42630. camera: ArcRotateCamera;
  42631. /**
  42632. * Defines the list of key codes associated with the up action (increase alpha)
  42633. */
  42634. keysUp: number[];
  42635. /**
  42636. * Defines the list of key codes associated with the down action (decrease alpha)
  42637. */
  42638. keysDown: number[];
  42639. /**
  42640. * Defines the list of key codes associated with the left action (increase beta)
  42641. */
  42642. keysLeft: number[];
  42643. /**
  42644. * Defines the list of key codes associated with the right action (decrease beta)
  42645. */
  42646. keysRight: number[];
  42647. /**
  42648. * Defines the list of key codes associated with the reset action.
  42649. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42650. */
  42651. keysReset: number[];
  42652. /**
  42653. * Defines the panning sensibility of the inputs.
  42654. * (How fast is the camera panning)
  42655. */
  42656. panningSensibility: number;
  42657. /**
  42658. * Defines the zooming sensibility of the inputs.
  42659. * (How fast is the camera zooming)
  42660. */
  42661. zoomingSensibility: number;
  42662. /**
  42663. * Defines whether maintaining the alt key down switch the movement mode from
  42664. * orientation to zoom.
  42665. */
  42666. useAltToZoom: boolean;
  42667. /**
  42668. * Rotation speed of the camera
  42669. */
  42670. angularSpeed: number;
  42671. private _keys;
  42672. private _ctrlPressed;
  42673. private _altPressed;
  42674. private _onCanvasBlurObserver;
  42675. private _onKeyboardObserver;
  42676. private _engine;
  42677. private _scene;
  42678. /**
  42679. * Attach the input controls to a specific dom element to get the input from.
  42680. * @param element Defines the element the controls should be listened from
  42681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42682. */
  42683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42684. /**
  42685. * Detach the current controls from the specified dom element.
  42686. * @param element Defines the element to stop listening the inputs from
  42687. */
  42688. detachControl(element: Nullable<HTMLElement>): void;
  42689. /**
  42690. * Update the current camera state depending on the inputs that have been used this frame.
  42691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42692. */
  42693. checkInputs(): void;
  42694. /**
  42695. * Gets the class name of the current intput.
  42696. * @returns the class name
  42697. */
  42698. getClassName(): string;
  42699. /**
  42700. * Get the friendly name associated with the input class.
  42701. * @returns the input friendly name
  42702. */
  42703. getSimpleName(): string;
  42704. }
  42705. }
  42706. declare module BABYLON {
  42707. /**
  42708. * Manage the mouse wheel inputs to control an arc rotate camera.
  42709. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42710. */
  42711. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42712. /**
  42713. * Defines the camera the input is attached to.
  42714. */
  42715. camera: ArcRotateCamera;
  42716. /**
  42717. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42718. */
  42719. wheelPrecision: number;
  42720. /**
  42721. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42722. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42723. */
  42724. wheelDeltaPercentage: number;
  42725. private _wheel;
  42726. private _observer;
  42727. private computeDeltaFromMouseWheelLegacyEvent;
  42728. /**
  42729. * Attach the input controls to a specific dom element to get the input from.
  42730. * @param element Defines the element the controls should be listened from
  42731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42732. */
  42733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42734. /**
  42735. * Detach the current controls from the specified dom element.
  42736. * @param element Defines the element to stop listening the inputs from
  42737. */
  42738. detachControl(element: Nullable<HTMLElement>): void;
  42739. /**
  42740. * Gets the class name of the current intput.
  42741. * @returns the class name
  42742. */
  42743. getClassName(): string;
  42744. /**
  42745. * Get the friendly name associated with the input class.
  42746. * @returns the input friendly name
  42747. */
  42748. getSimpleName(): string;
  42749. }
  42750. }
  42751. declare module BABYLON {
  42752. /**
  42753. * Default Inputs manager for the ArcRotateCamera.
  42754. * It groups all the default supported inputs for ease of use.
  42755. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42756. */
  42757. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42758. /**
  42759. * Instantiates a new ArcRotateCameraInputsManager.
  42760. * @param camera Defines the camera the inputs belong to
  42761. */
  42762. constructor(camera: ArcRotateCamera);
  42763. /**
  42764. * Add mouse wheel input support to the input manager.
  42765. * @returns the current input manager
  42766. */
  42767. addMouseWheel(): ArcRotateCameraInputsManager;
  42768. /**
  42769. * Add pointers input support to the input manager.
  42770. * @returns the current input manager
  42771. */
  42772. addPointers(): ArcRotateCameraInputsManager;
  42773. /**
  42774. * Add keyboard input support to the input manager.
  42775. * @returns the current input manager
  42776. */
  42777. addKeyboard(): ArcRotateCameraInputsManager;
  42778. }
  42779. }
  42780. declare module BABYLON {
  42781. /**
  42782. * This represents an orbital type of camera.
  42783. *
  42784. * 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.
  42785. * 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.
  42786. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42787. */
  42788. export class ArcRotateCamera extends TargetCamera {
  42789. /**
  42790. * Defines the rotation angle of the camera along the longitudinal axis.
  42791. */
  42792. alpha: number;
  42793. /**
  42794. * Defines the rotation angle of the camera along the latitudinal axis.
  42795. */
  42796. beta: number;
  42797. /**
  42798. * Defines the radius of the camera from it s target point.
  42799. */
  42800. radius: number;
  42801. protected _target: Vector3;
  42802. protected _targetHost: Nullable<AbstractMesh>;
  42803. /**
  42804. * Defines the target point of the camera.
  42805. * The camera looks towards it form the radius distance.
  42806. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42807. */
  42808. get target(): Vector3;
  42809. set target(value: Vector3);
  42810. /**
  42811. * Define the current local position of the camera in the scene
  42812. */
  42813. get position(): Vector3;
  42814. set position(newPosition: Vector3);
  42815. protected _upVector: Vector3;
  42816. protected _upToYMatrix: Matrix;
  42817. protected _YToUpMatrix: Matrix;
  42818. /**
  42819. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42820. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42821. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42822. */
  42823. set upVector(vec: Vector3);
  42824. get upVector(): Vector3;
  42825. /**
  42826. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42827. */
  42828. setMatUp(): void;
  42829. /**
  42830. * Current inertia value on the longitudinal axis.
  42831. * The bigger this number the longer it will take for the camera to stop.
  42832. */
  42833. inertialAlphaOffset: number;
  42834. /**
  42835. * Current inertia value on the latitudinal axis.
  42836. * The bigger this number the longer it will take for the camera to stop.
  42837. */
  42838. inertialBetaOffset: number;
  42839. /**
  42840. * Current inertia value on the radius axis.
  42841. * The bigger this number the longer it will take for the camera to stop.
  42842. */
  42843. inertialRadiusOffset: number;
  42844. /**
  42845. * Minimum allowed angle on the longitudinal axis.
  42846. * This can help limiting how the Camera is able to move in the scene.
  42847. */
  42848. lowerAlphaLimit: Nullable<number>;
  42849. /**
  42850. * Maximum allowed angle on the longitudinal axis.
  42851. * This can help limiting how the Camera is able to move in the scene.
  42852. */
  42853. upperAlphaLimit: Nullable<number>;
  42854. /**
  42855. * Minimum allowed angle on the latitudinal axis.
  42856. * This can help limiting how the Camera is able to move in the scene.
  42857. */
  42858. lowerBetaLimit: number;
  42859. /**
  42860. * Maximum allowed angle on the latitudinal axis.
  42861. * This can help limiting how the Camera is able to move in the scene.
  42862. */
  42863. upperBetaLimit: number;
  42864. /**
  42865. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42866. * This can help limiting how the Camera is able to move in the scene.
  42867. */
  42868. lowerRadiusLimit: Nullable<number>;
  42869. /**
  42870. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42871. * This can help limiting how the Camera is able to move in the scene.
  42872. */
  42873. upperRadiusLimit: Nullable<number>;
  42874. /**
  42875. * Defines the current inertia value used during panning of the camera along the X axis.
  42876. */
  42877. inertialPanningX: number;
  42878. /**
  42879. * Defines the current inertia value used during panning of the camera along the Y axis.
  42880. */
  42881. inertialPanningY: number;
  42882. /**
  42883. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42884. * Basically if your fingers moves away from more than this distance you will be considered
  42885. * in pinch mode.
  42886. */
  42887. pinchToPanMaxDistance: number;
  42888. /**
  42889. * Defines the maximum distance the camera can pan.
  42890. * This could help keeping the cammera always in your scene.
  42891. */
  42892. panningDistanceLimit: Nullable<number>;
  42893. /**
  42894. * Defines the target of the camera before paning.
  42895. */
  42896. panningOriginTarget: Vector3;
  42897. /**
  42898. * Defines the value of the inertia used during panning.
  42899. * 0 would mean stop inertia and one would mean no decelleration at all.
  42900. */
  42901. panningInertia: number;
  42902. /**
  42903. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42904. */
  42905. get angularSensibilityX(): number;
  42906. set angularSensibilityX(value: number);
  42907. /**
  42908. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42909. */
  42910. get angularSensibilityY(): number;
  42911. set angularSensibilityY(value: number);
  42912. /**
  42913. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42914. */
  42915. get pinchPrecision(): number;
  42916. set pinchPrecision(value: number);
  42917. /**
  42918. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42919. * It will be used instead of pinchDeltaPrecision if different from 0.
  42920. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42921. */
  42922. get pinchDeltaPercentage(): number;
  42923. set pinchDeltaPercentage(value: number);
  42924. /**
  42925. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42926. * and pinch delta percentage.
  42927. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42928. * that any object in the plane at the camera's target point will scale
  42929. * perfectly with finger motion.
  42930. */
  42931. get useNaturalPinchZoom(): boolean;
  42932. set useNaturalPinchZoom(value: boolean);
  42933. /**
  42934. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42935. */
  42936. get panningSensibility(): number;
  42937. set panningSensibility(value: number);
  42938. /**
  42939. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42940. */
  42941. get keysUp(): number[];
  42942. set keysUp(value: number[]);
  42943. /**
  42944. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42945. */
  42946. get keysDown(): number[];
  42947. set keysDown(value: number[]);
  42948. /**
  42949. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42950. */
  42951. get keysLeft(): number[];
  42952. set keysLeft(value: number[]);
  42953. /**
  42954. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42955. */
  42956. get keysRight(): number[];
  42957. set keysRight(value: number[]);
  42958. /**
  42959. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42960. */
  42961. get wheelPrecision(): number;
  42962. set wheelPrecision(value: number);
  42963. /**
  42964. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42965. * It will be used instead of pinchDeltaPrecision if different from 0.
  42966. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42967. */
  42968. get wheelDeltaPercentage(): number;
  42969. set wheelDeltaPercentage(value: number);
  42970. /**
  42971. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42972. */
  42973. zoomOnFactor: number;
  42974. /**
  42975. * Defines a screen offset for the camera position.
  42976. */
  42977. targetScreenOffset: Vector2;
  42978. /**
  42979. * Allows the camera to be completely reversed.
  42980. * If false the camera can not arrive upside down.
  42981. */
  42982. allowUpsideDown: boolean;
  42983. /**
  42984. * Define if double tap/click is used to restore the previously saved state of the camera.
  42985. */
  42986. useInputToRestoreState: boolean;
  42987. /** @hidden */
  42988. _viewMatrix: Matrix;
  42989. /** @hidden */
  42990. _useCtrlForPanning: boolean;
  42991. /** @hidden */
  42992. _panningMouseButton: number;
  42993. /**
  42994. * Defines the input associated to the camera.
  42995. */
  42996. inputs: ArcRotateCameraInputsManager;
  42997. /** @hidden */
  42998. _reset: () => void;
  42999. /**
  43000. * Defines the allowed panning axis.
  43001. */
  43002. panningAxis: Vector3;
  43003. protected _localDirection: Vector3;
  43004. protected _transformedDirection: Vector3;
  43005. private _bouncingBehavior;
  43006. /**
  43007. * Gets the bouncing behavior of the camera if it has been enabled.
  43008. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43009. */
  43010. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43011. /**
  43012. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43013. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43014. */
  43015. get useBouncingBehavior(): boolean;
  43016. set useBouncingBehavior(value: boolean);
  43017. private _framingBehavior;
  43018. /**
  43019. * Gets the framing behavior of the camera if it has been enabled.
  43020. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43021. */
  43022. get framingBehavior(): Nullable<FramingBehavior>;
  43023. /**
  43024. * Defines if the framing behavior of the camera is enabled on the camera.
  43025. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43026. */
  43027. get useFramingBehavior(): boolean;
  43028. set useFramingBehavior(value: boolean);
  43029. private _autoRotationBehavior;
  43030. /**
  43031. * Gets the auto rotation behavior of the camera if it has been enabled.
  43032. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43033. */
  43034. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43035. /**
  43036. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43037. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43038. */
  43039. get useAutoRotationBehavior(): boolean;
  43040. set useAutoRotationBehavior(value: boolean);
  43041. /**
  43042. * Observable triggered when the mesh target has been changed on the camera.
  43043. */
  43044. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43045. /**
  43046. * Event raised when the camera is colliding with a mesh.
  43047. */
  43048. onCollide: (collidedMesh: AbstractMesh) => void;
  43049. /**
  43050. * Defines whether the camera should check collision with the objects oh the scene.
  43051. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43052. */
  43053. checkCollisions: boolean;
  43054. /**
  43055. * Defines the collision radius of the camera.
  43056. * This simulates a sphere around the camera.
  43057. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43058. */
  43059. collisionRadius: Vector3;
  43060. protected _collider: Collider;
  43061. protected _previousPosition: Vector3;
  43062. protected _collisionVelocity: Vector3;
  43063. protected _newPosition: Vector3;
  43064. protected _previousAlpha: number;
  43065. protected _previousBeta: number;
  43066. protected _previousRadius: number;
  43067. protected _collisionTriggered: boolean;
  43068. protected _targetBoundingCenter: Nullable<Vector3>;
  43069. private _computationVector;
  43070. /**
  43071. * Instantiates a new ArcRotateCamera in a given scene
  43072. * @param name Defines the name of the camera
  43073. * @param alpha Defines the camera rotation along the logitudinal axis
  43074. * @param beta Defines the camera rotation along the latitudinal axis
  43075. * @param radius Defines the camera distance from its target
  43076. * @param target Defines the camera target
  43077. * @param scene Defines the scene the camera belongs to
  43078. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43079. */
  43080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43081. /** @hidden */
  43082. _initCache(): void;
  43083. /** @hidden */
  43084. _updateCache(ignoreParentClass?: boolean): void;
  43085. protected _getTargetPosition(): Vector3;
  43086. private _storedAlpha;
  43087. private _storedBeta;
  43088. private _storedRadius;
  43089. private _storedTarget;
  43090. private _storedTargetScreenOffset;
  43091. /**
  43092. * Stores the current state of the camera (alpha, beta, radius and target)
  43093. * @returns the camera itself
  43094. */
  43095. storeState(): Camera;
  43096. /**
  43097. * @hidden
  43098. * Restored camera state. You must call storeState() first
  43099. */
  43100. _restoreStateValues(): boolean;
  43101. /** @hidden */
  43102. _isSynchronizedViewMatrix(): boolean;
  43103. /**
  43104. * Attached controls to the current camera.
  43105. * @param element Defines the element the controls should be listened from
  43106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43107. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43108. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43109. */
  43110. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43111. /**
  43112. * Detach the current controls from the camera.
  43113. * The camera will stop reacting to inputs.
  43114. * @param element Defines the element to stop listening the inputs from
  43115. */
  43116. detachControl(element: HTMLElement): void;
  43117. /** @hidden */
  43118. _checkInputs(): void;
  43119. protected _checkLimits(): void;
  43120. /**
  43121. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43122. */
  43123. rebuildAnglesAndRadius(): void;
  43124. /**
  43125. * Use a position to define the current camera related information like alpha, beta and radius
  43126. * @param position Defines the position to set the camera at
  43127. */
  43128. setPosition(position: Vector3): void;
  43129. /**
  43130. * Defines the target the camera should look at.
  43131. * This will automatically adapt alpha beta and radius to fit within the new target.
  43132. * @param target Defines the new target as a Vector or a mesh
  43133. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43134. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43135. */
  43136. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43137. /** @hidden */
  43138. _getViewMatrix(): Matrix;
  43139. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43140. /**
  43141. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43142. * @param meshes Defines the mesh to zoom on
  43143. * @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)
  43144. */
  43145. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43146. /**
  43147. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43148. * The target will be changed but the radius
  43149. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43150. * @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)
  43151. */
  43152. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43153. min: Vector3;
  43154. max: Vector3;
  43155. distance: number;
  43156. }, doNotUpdateMaxZ?: boolean): void;
  43157. /**
  43158. * @override
  43159. * Override Camera.createRigCamera
  43160. */
  43161. createRigCamera(name: string, cameraIndex: number): Camera;
  43162. /**
  43163. * @hidden
  43164. * @override
  43165. * Override Camera._updateRigCameras
  43166. */
  43167. _updateRigCameras(): void;
  43168. /**
  43169. * Destroy the camera and release the current resources hold by it.
  43170. */
  43171. dispose(): void;
  43172. /**
  43173. * Gets the current object class name.
  43174. * @return the class name
  43175. */
  43176. getClassName(): string;
  43177. }
  43178. }
  43179. declare module BABYLON {
  43180. /**
  43181. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43182. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43183. */
  43184. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43185. /**
  43186. * Gets the name of the behavior.
  43187. */
  43188. get name(): string;
  43189. private _zoomStopsAnimation;
  43190. private _idleRotationSpeed;
  43191. private _idleRotationWaitTime;
  43192. private _idleRotationSpinupTime;
  43193. /**
  43194. * Sets the flag that indicates if user zooming should stop animation.
  43195. */
  43196. set zoomStopsAnimation(flag: boolean);
  43197. /**
  43198. * Gets the flag that indicates if user zooming should stop animation.
  43199. */
  43200. get zoomStopsAnimation(): boolean;
  43201. /**
  43202. * Sets the default speed at which the camera rotates around the model.
  43203. */
  43204. set idleRotationSpeed(speed: number);
  43205. /**
  43206. * Gets the default speed at which the camera rotates around the model.
  43207. */
  43208. get idleRotationSpeed(): number;
  43209. /**
  43210. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43211. */
  43212. set idleRotationWaitTime(time: number);
  43213. /**
  43214. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43215. */
  43216. get idleRotationWaitTime(): number;
  43217. /**
  43218. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43219. */
  43220. set idleRotationSpinupTime(time: number);
  43221. /**
  43222. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43223. */
  43224. get idleRotationSpinupTime(): number;
  43225. /**
  43226. * Gets a value indicating if the camera is currently rotating because of this behavior
  43227. */
  43228. get rotationInProgress(): boolean;
  43229. private _onPrePointerObservableObserver;
  43230. private _onAfterCheckInputsObserver;
  43231. private _attachedCamera;
  43232. private _isPointerDown;
  43233. private _lastFrameTime;
  43234. private _lastInteractionTime;
  43235. private _cameraRotationSpeed;
  43236. /**
  43237. * Initializes the behavior.
  43238. */
  43239. init(): void;
  43240. /**
  43241. * Attaches the behavior to its arc rotate camera.
  43242. * @param camera Defines the camera to attach the behavior to
  43243. */
  43244. attach(camera: ArcRotateCamera): void;
  43245. /**
  43246. * Detaches the behavior from its current arc rotate camera.
  43247. */
  43248. detach(): void;
  43249. /**
  43250. * Returns true if user is scrolling.
  43251. * @return true if user is scrolling.
  43252. */
  43253. private _userIsZooming;
  43254. private _lastFrameRadius;
  43255. private _shouldAnimationStopForInteraction;
  43256. /**
  43257. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43258. */
  43259. private _applyUserInteraction;
  43260. private _userIsMoving;
  43261. }
  43262. }
  43263. declare module BABYLON {
  43264. /**
  43265. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43266. */
  43267. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43268. private ui;
  43269. /**
  43270. * The name of the behavior
  43271. */
  43272. name: string;
  43273. /**
  43274. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43275. */
  43276. distanceAwayFromFace: number;
  43277. /**
  43278. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43279. */
  43280. distanceAwayFromBottomOfFace: number;
  43281. private _faceVectors;
  43282. private _target;
  43283. private _scene;
  43284. private _onRenderObserver;
  43285. private _tmpMatrix;
  43286. private _tmpVector;
  43287. /**
  43288. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43289. * @param ui The transform node that should be attched to the mesh
  43290. */
  43291. constructor(ui: TransformNode);
  43292. /**
  43293. * Initializes the behavior
  43294. */
  43295. init(): void;
  43296. private _closestFace;
  43297. private _zeroVector;
  43298. private _lookAtTmpMatrix;
  43299. private _lookAtToRef;
  43300. /**
  43301. * Attaches the AttachToBoxBehavior to the passed in mesh
  43302. * @param target The mesh that the specified node will be attached to
  43303. */
  43304. attach(target: Mesh): void;
  43305. /**
  43306. * Detaches the behavior from the mesh
  43307. */
  43308. detach(): void;
  43309. }
  43310. }
  43311. declare module BABYLON {
  43312. /**
  43313. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43314. */
  43315. export class FadeInOutBehavior implements Behavior<Mesh> {
  43316. /**
  43317. * Time in milliseconds to delay before fading in (Default: 0)
  43318. */
  43319. delay: number;
  43320. /**
  43321. * Time in milliseconds for the mesh to fade in (Default: 300)
  43322. */
  43323. fadeInTime: number;
  43324. private _millisecondsPerFrame;
  43325. private _hovered;
  43326. private _hoverValue;
  43327. private _ownerNode;
  43328. /**
  43329. * Instatiates the FadeInOutBehavior
  43330. */
  43331. constructor();
  43332. /**
  43333. * The name of the behavior
  43334. */
  43335. get name(): string;
  43336. /**
  43337. * Initializes the behavior
  43338. */
  43339. init(): void;
  43340. /**
  43341. * Attaches the fade behavior on the passed in mesh
  43342. * @param ownerNode The mesh that will be faded in/out once attached
  43343. */
  43344. attach(ownerNode: Mesh): void;
  43345. /**
  43346. * Detaches the behavior from the mesh
  43347. */
  43348. detach(): void;
  43349. /**
  43350. * Triggers the mesh to begin fading in or out
  43351. * @param value if the object should fade in or out (true to fade in)
  43352. */
  43353. fadeIn(value: boolean): void;
  43354. private _update;
  43355. private _setAllVisibility;
  43356. }
  43357. }
  43358. declare module BABYLON {
  43359. /**
  43360. * Class containing a set of static utilities functions for managing Pivots
  43361. * @hidden
  43362. */
  43363. export class PivotTools {
  43364. private static _PivotCached;
  43365. private static _OldPivotPoint;
  43366. private static _PivotTranslation;
  43367. private static _PivotTmpVector;
  43368. /** @hidden */
  43369. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43370. /** @hidden */
  43371. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43372. }
  43373. }
  43374. declare module BABYLON {
  43375. /**
  43376. * Class containing static functions to help procedurally build meshes
  43377. */
  43378. export class PlaneBuilder {
  43379. /**
  43380. * Creates a plane mesh
  43381. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43382. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43383. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43385. * * 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
  43386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43387. * @param name defines the name of the mesh
  43388. * @param options defines the options used to create the mesh
  43389. * @param scene defines the hosting scene
  43390. * @returns the plane mesh
  43391. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43392. */
  43393. static CreatePlane(name: string, options: {
  43394. size?: number;
  43395. width?: number;
  43396. height?: number;
  43397. sideOrientation?: number;
  43398. frontUVs?: Vector4;
  43399. backUVs?: Vector4;
  43400. updatable?: boolean;
  43401. sourcePlane?: Plane;
  43402. }, scene?: Nullable<Scene>): Mesh;
  43403. }
  43404. }
  43405. declare module BABYLON {
  43406. /**
  43407. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43408. */
  43409. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43410. private static _AnyMouseID;
  43411. /**
  43412. * Abstract mesh the behavior is set on
  43413. */
  43414. attachedNode: AbstractMesh;
  43415. private _dragPlane;
  43416. private _scene;
  43417. private _pointerObserver;
  43418. private _beforeRenderObserver;
  43419. private static _planeScene;
  43420. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43421. /**
  43422. * 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)
  43423. */
  43424. maxDragAngle: number;
  43425. /**
  43426. * @hidden
  43427. */
  43428. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43429. /**
  43430. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43431. */
  43432. currentDraggingPointerID: number;
  43433. /**
  43434. * The last position where the pointer hit the drag plane in world space
  43435. */
  43436. lastDragPosition: Vector3;
  43437. /**
  43438. * If the behavior is currently in a dragging state
  43439. */
  43440. dragging: boolean;
  43441. /**
  43442. * 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)
  43443. */
  43444. dragDeltaRatio: number;
  43445. /**
  43446. * If the drag plane orientation should be updated during the dragging (Default: true)
  43447. */
  43448. updateDragPlane: boolean;
  43449. private _debugMode;
  43450. private _moving;
  43451. /**
  43452. * Fires each time the attached mesh is dragged with the pointer
  43453. * * delta between last drag position and current drag position in world space
  43454. * * dragDistance along the drag axis
  43455. * * dragPlaneNormal normal of the current drag plane used during the drag
  43456. * * dragPlanePoint in world space where the drag intersects the drag plane
  43457. */
  43458. onDragObservable: Observable<{
  43459. delta: Vector3;
  43460. dragPlanePoint: Vector3;
  43461. dragPlaneNormal: Vector3;
  43462. dragDistance: number;
  43463. pointerId: number;
  43464. }>;
  43465. /**
  43466. * Fires each time a drag begins (eg. mouse down on mesh)
  43467. */
  43468. onDragStartObservable: Observable<{
  43469. dragPlanePoint: Vector3;
  43470. pointerId: number;
  43471. }>;
  43472. /**
  43473. * Fires each time a drag ends (eg. mouse release after drag)
  43474. */
  43475. onDragEndObservable: Observable<{
  43476. dragPlanePoint: Vector3;
  43477. pointerId: number;
  43478. }>;
  43479. /**
  43480. * If the attached mesh should be moved when dragged
  43481. */
  43482. moveAttached: boolean;
  43483. /**
  43484. * If the drag behavior will react to drag events (Default: true)
  43485. */
  43486. enabled: boolean;
  43487. /**
  43488. * If pointer events should start and release the drag (Default: true)
  43489. */
  43490. startAndReleaseDragOnPointerEvents: boolean;
  43491. /**
  43492. * If camera controls should be detached during the drag
  43493. */
  43494. detachCameraControls: boolean;
  43495. /**
  43496. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43497. */
  43498. useObjectOrientationForDragging: boolean;
  43499. private _options;
  43500. /**
  43501. * Gets the options used by the behavior
  43502. */
  43503. get options(): {
  43504. dragAxis?: Vector3;
  43505. dragPlaneNormal?: Vector3;
  43506. };
  43507. /**
  43508. * Sets the options used by the behavior
  43509. */
  43510. set options(options: {
  43511. dragAxis?: Vector3;
  43512. dragPlaneNormal?: Vector3;
  43513. });
  43514. /**
  43515. * Creates a pointer drag behavior that can be attached to a mesh
  43516. * @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)
  43517. */
  43518. constructor(options?: {
  43519. dragAxis?: Vector3;
  43520. dragPlaneNormal?: Vector3;
  43521. });
  43522. /**
  43523. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43524. */
  43525. validateDrag: (targetPosition: Vector3) => boolean;
  43526. /**
  43527. * The name of the behavior
  43528. */
  43529. get name(): string;
  43530. /**
  43531. * Initializes the behavior
  43532. */
  43533. init(): void;
  43534. private _tmpVector;
  43535. private _alternatePickedPoint;
  43536. private _worldDragAxis;
  43537. private _targetPosition;
  43538. private _attachedElement;
  43539. /**
  43540. * Attaches the drag behavior the passed in mesh
  43541. * @param ownerNode The mesh that will be dragged around once attached
  43542. * @param predicate Predicate to use for pick filtering
  43543. */
  43544. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43545. /**
  43546. * Force relase the drag action by code.
  43547. */
  43548. releaseDrag(): void;
  43549. private _startDragRay;
  43550. private _lastPointerRay;
  43551. /**
  43552. * Simulates the start of a pointer drag event on the behavior
  43553. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43554. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43555. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43556. */
  43557. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43558. private _startDrag;
  43559. private _dragDelta;
  43560. private _moveDrag;
  43561. private _pickWithRayOnDragPlane;
  43562. private _pointA;
  43563. private _pointC;
  43564. private _localAxis;
  43565. private _lookAt;
  43566. private _updateDragPlanePosition;
  43567. /**
  43568. * Detaches the behavior from the mesh
  43569. */
  43570. detach(): void;
  43571. }
  43572. }
  43573. declare module BABYLON {
  43574. /**
  43575. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43576. */
  43577. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43578. private _dragBehaviorA;
  43579. private _dragBehaviorB;
  43580. private _startDistance;
  43581. private _initialScale;
  43582. private _targetScale;
  43583. private _ownerNode;
  43584. private _sceneRenderObserver;
  43585. /**
  43586. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43587. */
  43588. constructor();
  43589. /**
  43590. * The name of the behavior
  43591. */
  43592. get name(): string;
  43593. /**
  43594. * Initializes the behavior
  43595. */
  43596. init(): void;
  43597. private _getCurrentDistance;
  43598. /**
  43599. * Attaches the scale behavior the passed in mesh
  43600. * @param ownerNode The mesh that will be scaled around once attached
  43601. */
  43602. attach(ownerNode: Mesh): void;
  43603. /**
  43604. * Detaches the behavior from the mesh
  43605. */
  43606. detach(): void;
  43607. }
  43608. }
  43609. declare module BABYLON {
  43610. /**
  43611. * 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
  43612. */
  43613. export class SixDofDragBehavior implements Behavior<Mesh> {
  43614. private static _virtualScene;
  43615. private _ownerNode;
  43616. private _sceneRenderObserver;
  43617. private _scene;
  43618. private _targetPosition;
  43619. private _virtualOriginMesh;
  43620. private _virtualDragMesh;
  43621. private _pointerObserver;
  43622. private _moving;
  43623. private _startingOrientation;
  43624. private _attachedElement;
  43625. /**
  43626. * 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)
  43627. */
  43628. private zDragFactor;
  43629. /**
  43630. * If the object should rotate to face the drag origin
  43631. */
  43632. rotateDraggedObject: boolean;
  43633. /**
  43634. * If the behavior is currently in a dragging state
  43635. */
  43636. dragging: boolean;
  43637. /**
  43638. * 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)
  43639. */
  43640. dragDeltaRatio: number;
  43641. /**
  43642. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43643. */
  43644. currentDraggingPointerID: number;
  43645. /**
  43646. * If camera controls should be detached during the drag
  43647. */
  43648. detachCameraControls: boolean;
  43649. /**
  43650. * Fires each time a drag starts
  43651. */
  43652. onDragStartObservable: Observable<{}>;
  43653. /**
  43654. * Fires each time a drag ends (eg. mouse release after drag)
  43655. */
  43656. onDragEndObservable: Observable<{}>;
  43657. /**
  43658. * 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
  43659. */
  43660. constructor();
  43661. /**
  43662. * The name of the behavior
  43663. */
  43664. get name(): string;
  43665. /**
  43666. * Initializes the behavior
  43667. */
  43668. init(): void;
  43669. /**
  43670. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43671. */
  43672. private get _pointerCamera();
  43673. /**
  43674. * Attaches the scale behavior the passed in mesh
  43675. * @param ownerNode The mesh that will be scaled around once attached
  43676. */
  43677. attach(ownerNode: Mesh): void;
  43678. /**
  43679. * Detaches the behavior from the mesh
  43680. */
  43681. detach(): void;
  43682. }
  43683. }
  43684. declare module BABYLON {
  43685. /**
  43686. * Class used to apply inverse kinematics to bones
  43687. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43688. */
  43689. export class BoneIKController {
  43690. private static _tmpVecs;
  43691. private static _tmpQuat;
  43692. private static _tmpMats;
  43693. /**
  43694. * Gets or sets the target mesh
  43695. */
  43696. targetMesh: AbstractMesh;
  43697. /** Gets or sets the mesh used as pole */
  43698. poleTargetMesh: AbstractMesh;
  43699. /**
  43700. * Gets or sets the bone used as pole
  43701. */
  43702. poleTargetBone: Nullable<Bone>;
  43703. /**
  43704. * Gets or sets the target position
  43705. */
  43706. targetPosition: Vector3;
  43707. /**
  43708. * Gets or sets the pole target position
  43709. */
  43710. poleTargetPosition: Vector3;
  43711. /**
  43712. * Gets or sets the pole target local offset
  43713. */
  43714. poleTargetLocalOffset: Vector3;
  43715. /**
  43716. * Gets or sets the pole angle
  43717. */
  43718. poleAngle: number;
  43719. /**
  43720. * Gets or sets the mesh associated with the controller
  43721. */
  43722. mesh: AbstractMesh;
  43723. /**
  43724. * 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)
  43725. */
  43726. slerpAmount: number;
  43727. private _bone1Quat;
  43728. private _bone1Mat;
  43729. private _bone2Ang;
  43730. private _bone1;
  43731. private _bone2;
  43732. private _bone1Length;
  43733. private _bone2Length;
  43734. private _maxAngle;
  43735. private _maxReach;
  43736. private _rightHandedSystem;
  43737. private _bendAxis;
  43738. private _slerping;
  43739. private _adjustRoll;
  43740. /**
  43741. * Gets or sets maximum allowed angle
  43742. */
  43743. get maxAngle(): number;
  43744. set maxAngle(value: number);
  43745. /**
  43746. * Creates a new BoneIKController
  43747. * @param mesh defines the mesh to control
  43748. * @param bone defines the bone to control
  43749. * @param options defines options to set up the controller
  43750. */
  43751. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43752. targetMesh?: AbstractMesh;
  43753. poleTargetMesh?: AbstractMesh;
  43754. poleTargetBone?: Bone;
  43755. poleTargetLocalOffset?: Vector3;
  43756. poleAngle?: number;
  43757. bendAxis?: Vector3;
  43758. maxAngle?: number;
  43759. slerpAmount?: number;
  43760. });
  43761. private _setMaxAngle;
  43762. /**
  43763. * Force the controller to update the bones
  43764. */
  43765. update(): void;
  43766. }
  43767. }
  43768. declare module BABYLON {
  43769. /**
  43770. * Class used to make a bone look toward a point in space
  43771. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43772. */
  43773. export class BoneLookController {
  43774. private static _tmpVecs;
  43775. private static _tmpQuat;
  43776. private static _tmpMats;
  43777. /**
  43778. * The target Vector3 that the bone will look at
  43779. */
  43780. target: Vector3;
  43781. /**
  43782. * The mesh that the bone is attached to
  43783. */
  43784. mesh: AbstractMesh;
  43785. /**
  43786. * The bone that will be looking to the target
  43787. */
  43788. bone: Bone;
  43789. /**
  43790. * The up axis of the coordinate system that is used when the bone is rotated
  43791. */
  43792. upAxis: Vector3;
  43793. /**
  43794. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43795. */
  43796. upAxisSpace: Space;
  43797. /**
  43798. * Used to make an adjustment to the yaw of the bone
  43799. */
  43800. adjustYaw: number;
  43801. /**
  43802. * Used to make an adjustment to the pitch of the bone
  43803. */
  43804. adjustPitch: number;
  43805. /**
  43806. * Used to make an adjustment to the roll of the bone
  43807. */
  43808. adjustRoll: number;
  43809. /**
  43810. * 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)
  43811. */
  43812. slerpAmount: number;
  43813. private _minYaw;
  43814. private _maxYaw;
  43815. private _minPitch;
  43816. private _maxPitch;
  43817. private _minYawSin;
  43818. private _minYawCos;
  43819. private _maxYawSin;
  43820. private _maxYawCos;
  43821. private _midYawConstraint;
  43822. private _minPitchTan;
  43823. private _maxPitchTan;
  43824. private _boneQuat;
  43825. private _slerping;
  43826. private _transformYawPitch;
  43827. private _transformYawPitchInv;
  43828. private _firstFrameSkipped;
  43829. private _yawRange;
  43830. private _fowardAxis;
  43831. /**
  43832. * Gets or sets the minimum yaw angle that the bone can look to
  43833. */
  43834. get minYaw(): number;
  43835. set minYaw(value: number);
  43836. /**
  43837. * Gets or sets the maximum yaw angle that the bone can look to
  43838. */
  43839. get maxYaw(): number;
  43840. set maxYaw(value: number);
  43841. /**
  43842. * Gets or sets the minimum pitch angle that the bone can look to
  43843. */
  43844. get minPitch(): number;
  43845. set minPitch(value: number);
  43846. /**
  43847. * Gets or sets the maximum pitch angle that the bone can look to
  43848. */
  43849. get maxPitch(): number;
  43850. set maxPitch(value: number);
  43851. /**
  43852. * Create a BoneLookController
  43853. * @param mesh the mesh that the bone belongs to
  43854. * @param bone the bone that will be looking to the target
  43855. * @param target the target Vector3 to look at
  43856. * @param options optional settings:
  43857. * * maxYaw: the maximum angle the bone will yaw to
  43858. * * minYaw: the minimum angle the bone will yaw to
  43859. * * maxPitch: the maximum angle the bone will pitch to
  43860. * * minPitch: the minimum angle the bone will yaw to
  43861. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43862. * * upAxis: the up axis of the coordinate system
  43863. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43864. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43865. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43866. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43867. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43868. * * adjustRoll: used to make an adjustment to the roll of the bone
  43869. **/
  43870. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43871. maxYaw?: number;
  43872. minYaw?: number;
  43873. maxPitch?: number;
  43874. minPitch?: number;
  43875. slerpAmount?: number;
  43876. upAxis?: Vector3;
  43877. upAxisSpace?: Space;
  43878. yawAxis?: Vector3;
  43879. pitchAxis?: Vector3;
  43880. adjustYaw?: number;
  43881. adjustPitch?: number;
  43882. adjustRoll?: number;
  43883. });
  43884. /**
  43885. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43886. */
  43887. update(): void;
  43888. private _getAngleDiff;
  43889. private _getAngleBetween;
  43890. private _isAngleBetween;
  43891. }
  43892. }
  43893. declare module BABYLON {
  43894. /**
  43895. * Manage the gamepad inputs to control an arc rotate camera.
  43896. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43897. */
  43898. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43899. /**
  43900. * Defines the camera the input is attached to.
  43901. */
  43902. camera: ArcRotateCamera;
  43903. /**
  43904. * Defines the gamepad the input is gathering event from.
  43905. */
  43906. gamepad: Nullable<Gamepad>;
  43907. /**
  43908. * Defines the gamepad rotation sensiblity.
  43909. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43910. */
  43911. gamepadRotationSensibility: number;
  43912. /**
  43913. * Defines the gamepad move sensiblity.
  43914. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43915. */
  43916. gamepadMoveSensibility: number;
  43917. private _yAxisScale;
  43918. /**
  43919. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43920. */
  43921. get invertYAxis(): boolean;
  43922. set invertYAxis(value: boolean);
  43923. private _onGamepadConnectedObserver;
  43924. private _onGamepadDisconnectedObserver;
  43925. /**
  43926. * Attach the input controls to a specific dom element to get the input from.
  43927. * @param element Defines the element the controls should be listened from
  43928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43929. */
  43930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43931. /**
  43932. * Detach the current controls from the specified dom element.
  43933. * @param element Defines the element to stop listening the inputs from
  43934. */
  43935. detachControl(element: Nullable<HTMLElement>): void;
  43936. /**
  43937. * Update the current camera state depending on the inputs that have been used this frame.
  43938. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43939. */
  43940. checkInputs(): void;
  43941. /**
  43942. * Gets the class name of the current intput.
  43943. * @returns the class name
  43944. */
  43945. getClassName(): string;
  43946. /**
  43947. * Get the friendly name associated with the input class.
  43948. * @returns the input friendly name
  43949. */
  43950. getSimpleName(): string;
  43951. }
  43952. }
  43953. declare module BABYLON {
  43954. interface ArcRotateCameraInputsManager {
  43955. /**
  43956. * Add orientation input support to the input manager.
  43957. * @returns the current input manager
  43958. */
  43959. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43960. }
  43961. /**
  43962. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43964. */
  43965. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43966. /**
  43967. * Defines the camera the input is attached to.
  43968. */
  43969. camera: ArcRotateCamera;
  43970. /**
  43971. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43972. */
  43973. alphaCorrection: number;
  43974. /**
  43975. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43976. */
  43977. gammaCorrection: number;
  43978. private _alpha;
  43979. private _gamma;
  43980. private _dirty;
  43981. private _deviceOrientationHandler;
  43982. /**
  43983. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43984. */
  43985. constructor();
  43986. /**
  43987. * Attach the input controls to a specific dom element to get the input from.
  43988. * @param element Defines the element the controls should be listened from
  43989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43990. */
  43991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43992. /** @hidden */
  43993. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43994. /**
  43995. * Update the current camera state depending on the inputs that have been used this frame.
  43996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43997. */
  43998. checkInputs(): void;
  43999. /**
  44000. * Detach the current controls from the specified dom element.
  44001. * @param element Defines the element to stop listening the inputs from
  44002. */
  44003. detachControl(element: Nullable<HTMLElement>): void;
  44004. /**
  44005. * Gets the class name of the current intput.
  44006. * @returns the class name
  44007. */
  44008. getClassName(): string;
  44009. /**
  44010. * Get the friendly name associated with the input class.
  44011. * @returns the input friendly name
  44012. */
  44013. getSimpleName(): string;
  44014. }
  44015. }
  44016. declare module BABYLON {
  44017. /**
  44018. * Listen to mouse events to control the camera.
  44019. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44020. */
  44021. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44022. /**
  44023. * Defines the camera the input is attached to.
  44024. */
  44025. camera: FlyCamera;
  44026. /**
  44027. * Defines if touch is enabled. (Default is true.)
  44028. */
  44029. touchEnabled: boolean;
  44030. /**
  44031. * Defines the buttons associated with the input to handle camera rotation.
  44032. */
  44033. buttons: number[];
  44034. /**
  44035. * Assign buttons for Yaw control.
  44036. */
  44037. buttonsYaw: number[];
  44038. /**
  44039. * Assign buttons for Pitch control.
  44040. */
  44041. buttonsPitch: number[];
  44042. /**
  44043. * Assign buttons for Roll control.
  44044. */
  44045. buttonsRoll: number[];
  44046. /**
  44047. * Detect if any button is being pressed while mouse is moved.
  44048. * -1 = Mouse locked.
  44049. * 0 = Left button.
  44050. * 1 = Middle Button.
  44051. * 2 = Right Button.
  44052. */
  44053. activeButton: number;
  44054. /**
  44055. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44056. * Higher values reduce its sensitivity.
  44057. */
  44058. angularSensibility: number;
  44059. private _mousemoveCallback;
  44060. private _observer;
  44061. private _rollObserver;
  44062. private previousPosition;
  44063. private noPreventDefault;
  44064. private element;
  44065. /**
  44066. * Listen to mouse events to control the camera.
  44067. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44068. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44069. */
  44070. constructor(touchEnabled?: boolean);
  44071. /**
  44072. * Attach the mouse control to the HTML DOM element.
  44073. * @param element Defines the element that listens to the input events.
  44074. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44075. */
  44076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44077. /**
  44078. * Detach the current controls from the specified dom element.
  44079. * @param element Defines the element to stop listening the inputs from
  44080. */
  44081. detachControl(element: Nullable<HTMLElement>): void;
  44082. /**
  44083. * Gets the class name of the current input.
  44084. * @returns the class name.
  44085. */
  44086. getClassName(): string;
  44087. /**
  44088. * Get the friendly name associated with the input class.
  44089. * @returns the input's friendly name.
  44090. */
  44091. getSimpleName(): string;
  44092. private _pointerInput;
  44093. private _onMouseMove;
  44094. /**
  44095. * Rotate camera by mouse offset.
  44096. */
  44097. private rotateCamera;
  44098. }
  44099. }
  44100. declare module BABYLON {
  44101. /**
  44102. * Default Inputs manager for the FlyCamera.
  44103. * It groups all the default supported inputs for ease of use.
  44104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44105. */
  44106. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44107. /**
  44108. * Instantiates a new FlyCameraInputsManager.
  44109. * @param camera Defines the camera the inputs belong to.
  44110. */
  44111. constructor(camera: FlyCamera);
  44112. /**
  44113. * Add keyboard input support to the input manager.
  44114. * @returns the new FlyCameraKeyboardMoveInput().
  44115. */
  44116. addKeyboard(): FlyCameraInputsManager;
  44117. /**
  44118. * Add mouse input support to the input manager.
  44119. * @param touchEnabled Enable touch screen support.
  44120. * @returns the new FlyCameraMouseInput().
  44121. */
  44122. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44123. }
  44124. }
  44125. declare module BABYLON {
  44126. /**
  44127. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44128. * such as in a 3D Space Shooter or a Flight Simulator.
  44129. */
  44130. export class FlyCamera extends TargetCamera {
  44131. /**
  44132. * Define the collision ellipsoid of the camera.
  44133. * This is helpful for simulating a camera body, like a player's body.
  44134. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44135. */
  44136. ellipsoid: Vector3;
  44137. /**
  44138. * Define an offset for the position of the ellipsoid around the camera.
  44139. * This can be helpful if the camera is attached away from the player's body center,
  44140. * such as at its head.
  44141. */
  44142. ellipsoidOffset: Vector3;
  44143. /**
  44144. * Enable or disable collisions of the camera with the rest of the scene objects.
  44145. */
  44146. checkCollisions: boolean;
  44147. /**
  44148. * Enable or disable gravity on the camera.
  44149. */
  44150. applyGravity: boolean;
  44151. /**
  44152. * Define the current direction the camera is moving to.
  44153. */
  44154. cameraDirection: Vector3;
  44155. /**
  44156. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44157. * This overrides and empties cameraRotation.
  44158. */
  44159. rotationQuaternion: Quaternion;
  44160. /**
  44161. * Track Roll to maintain the wanted Rolling when looking around.
  44162. */
  44163. _trackRoll: number;
  44164. /**
  44165. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44166. */
  44167. rollCorrect: number;
  44168. /**
  44169. * Mimic a banked turn, Rolling the camera when Yawing.
  44170. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44171. */
  44172. bankedTurn: boolean;
  44173. /**
  44174. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44175. */
  44176. bankedTurnLimit: number;
  44177. /**
  44178. * Value of 0 disables the banked Roll.
  44179. * Value of 1 is equal to the Yaw angle in radians.
  44180. */
  44181. bankedTurnMultiplier: number;
  44182. /**
  44183. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44184. */
  44185. inputs: FlyCameraInputsManager;
  44186. /**
  44187. * Gets the input sensibility for mouse input.
  44188. * Higher values reduce sensitivity.
  44189. */
  44190. get angularSensibility(): number;
  44191. /**
  44192. * Sets the input sensibility for a mouse input.
  44193. * Higher values reduce sensitivity.
  44194. */
  44195. set angularSensibility(value: number);
  44196. /**
  44197. * Get the keys for camera movement forward.
  44198. */
  44199. get keysForward(): number[];
  44200. /**
  44201. * Set the keys for camera movement forward.
  44202. */
  44203. set keysForward(value: number[]);
  44204. /**
  44205. * Get the keys for camera movement backward.
  44206. */
  44207. get keysBackward(): number[];
  44208. set keysBackward(value: number[]);
  44209. /**
  44210. * Get the keys for camera movement up.
  44211. */
  44212. get keysUp(): number[];
  44213. /**
  44214. * Set the keys for camera movement up.
  44215. */
  44216. set keysUp(value: number[]);
  44217. /**
  44218. * Get the keys for camera movement down.
  44219. */
  44220. get keysDown(): number[];
  44221. /**
  44222. * Set the keys for camera movement down.
  44223. */
  44224. set keysDown(value: number[]);
  44225. /**
  44226. * Get the keys for camera movement left.
  44227. */
  44228. get keysLeft(): number[];
  44229. /**
  44230. * Set the keys for camera movement left.
  44231. */
  44232. set keysLeft(value: number[]);
  44233. /**
  44234. * Set the keys for camera movement right.
  44235. */
  44236. get keysRight(): number[];
  44237. /**
  44238. * Set the keys for camera movement right.
  44239. */
  44240. set keysRight(value: number[]);
  44241. /**
  44242. * Event raised when the camera collides with a mesh in the scene.
  44243. */
  44244. onCollide: (collidedMesh: AbstractMesh) => void;
  44245. private _collider;
  44246. private _needMoveForGravity;
  44247. private _oldPosition;
  44248. private _diffPosition;
  44249. private _newPosition;
  44250. /** @hidden */
  44251. _localDirection: Vector3;
  44252. /** @hidden */
  44253. _transformedDirection: Vector3;
  44254. /**
  44255. * Instantiates a FlyCamera.
  44256. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44257. * such as in a 3D Space Shooter or a Flight Simulator.
  44258. * @param name Define the name of the camera in the scene.
  44259. * @param position Define the starting position of the camera in the scene.
  44260. * @param scene Define the scene the camera belongs to.
  44261. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44262. */
  44263. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44264. /**
  44265. * Attach a control to the HTML DOM element.
  44266. * @param element Defines the element that listens to the input events.
  44267. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44268. */
  44269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44270. /**
  44271. * Detach a control from the HTML DOM element.
  44272. * The camera will stop reacting to that input.
  44273. * @param element Defines the element that listens to the input events.
  44274. */
  44275. detachControl(element: HTMLElement): void;
  44276. private _collisionMask;
  44277. /**
  44278. * Get the mask that the camera ignores in collision events.
  44279. */
  44280. get collisionMask(): number;
  44281. /**
  44282. * Set the mask that the camera ignores in collision events.
  44283. */
  44284. set collisionMask(mask: number);
  44285. /** @hidden */
  44286. _collideWithWorld(displacement: Vector3): void;
  44287. /** @hidden */
  44288. private _onCollisionPositionChange;
  44289. /** @hidden */
  44290. _checkInputs(): void;
  44291. /** @hidden */
  44292. _decideIfNeedsToMove(): boolean;
  44293. /** @hidden */
  44294. _updatePosition(): void;
  44295. /**
  44296. * Restore the Roll to its target value at the rate specified.
  44297. * @param rate - Higher means slower restoring.
  44298. * @hidden
  44299. */
  44300. restoreRoll(rate: number): void;
  44301. /**
  44302. * Destroy the camera and release the current resources held by it.
  44303. */
  44304. dispose(): void;
  44305. /**
  44306. * Get the current object class name.
  44307. * @returns the class name.
  44308. */
  44309. getClassName(): string;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * Listen to keyboard events to control the camera.
  44315. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44316. */
  44317. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44318. /**
  44319. * Defines the camera the input is attached to.
  44320. */
  44321. camera: FlyCamera;
  44322. /**
  44323. * The list of keyboard keys used to control the forward move of the camera.
  44324. */
  44325. keysForward: number[];
  44326. /**
  44327. * The list of keyboard keys used to control the backward move of the camera.
  44328. */
  44329. keysBackward: number[];
  44330. /**
  44331. * The list of keyboard keys used to control the forward move of the camera.
  44332. */
  44333. keysUp: number[];
  44334. /**
  44335. * The list of keyboard keys used to control the backward move of the camera.
  44336. */
  44337. keysDown: number[];
  44338. /**
  44339. * The list of keyboard keys used to control the right strafe move of the camera.
  44340. */
  44341. keysRight: number[];
  44342. /**
  44343. * The list of keyboard keys used to control the left strafe move of the camera.
  44344. */
  44345. keysLeft: number[];
  44346. private _keys;
  44347. private _onCanvasBlurObserver;
  44348. private _onKeyboardObserver;
  44349. private _engine;
  44350. private _scene;
  44351. /**
  44352. * Attach the input controls to a specific dom element to get the input from.
  44353. * @param element Defines the element the controls should be listened from
  44354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44355. */
  44356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44357. /**
  44358. * Detach the current controls from the specified dom element.
  44359. * @param element Defines the element to stop listening the inputs from
  44360. */
  44361. detachControl(element: Nullable<HTMLElement>): void;
  44362. /**
  44363. * Gets the class name of the current intput.
  44364. * @returns the class name
  44365. */
  44366. getClassName(): string;
  44367. /** @hidden */
  44368. _onLostFocus(e: FocusEvent): void;
  44369. /**
  44370. * Get the friendly name associated with the input class.
  44371. * @returns the input friendly name
  44372. */
  44373. getSimpleName(): string;
  44374. /**
  44375. * Update the current camera state depending on the inputs that have been used this frame.
  44376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44377. */
  44378. checkInputs(): void;
  44379. }
  44380. }
  44381. declare module BABYLON {
  44382. /**
  44383. * Manage the mouse wheel inputs to control a follow camera.
  44384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44385. */
  44386. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44387. /**
  44388. * Defines the camera the input is attached to.
  44389. */
  44390. camera: FollowCamera;
  44391. /**
  44392. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44393. */
  44394. axisControlRadius: boolean;
  44395. /**
  44396. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44397. */
  44398. axisControlHeight: boolean;
  44399. /**
  44400. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44401. */
  44402. axisControlRotation: boolean;
  44403. /**
  44404. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44405. * relation to mouseWheel events.
  44406. */
  44407. wheelPrecision: number;
  44408. /**
  44409. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44410. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44411. */
  44412. wheelDeltaPercentage: number;
  44413. private _wheel;
  44414. private _observer;
  44415. /**
  44416. * Attach the input controls to a specific dom element to get the input from.
  44417. * @param element Defines the element the controls should be listened from
  44418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44419. */
  44420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44421. /**
  44422. * Detach the current controls from the specified dom element.
  44423. * @param element Defines the element to stop listening the inputs from
  44424. */
  44425. detachControl(element: Nullable<HTMLElement>): void;
  44426. /**
  44427. * Gets the class name of the current intput.
  44428. * @returns the class name
  44429. */
  44430. getClassName(): string;
  44431. /**
  44432. * Get the friendly name associated with the input class.
  44433. * @returns the input friendly name
  44434. */
  44435. getSimpleName(): string;
  44436. }
  44437. }
  44438. declare module BABYLON {
  44439. /**
  44440. * Manage the pointers inputs to control an follow camera.
  44441. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44442. */
  44443. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44444. /**
  44445. * Defines the camera the input is attached to.
  44446. */
  44447. camera: FollowCamera;
  44448. /**
  44449. * Gets the class name of the current input.
  44450. * @returns the class name
  44451. */
  44452. getClassName(): string;
  44453. /**
  44454. * Defines the pointer angular sensibility along the X axis or how fast is
  44455. * the camera rotating.
  44456. * A negative number will reverse the axis direction.
  44457. */
  44458. angularSensibilityX: number;
  44459. /**
  44460. * Defines the pointer angular sensibility along the Y axis or how fast is
  44461. * the camera rotating.
  44462. * A negative number will reverse the axis direction.
  44463. */
  44464. angularSensibilityY: number;
  44465. /**
  44466. * Defines the pointer pinch precision or how fast is the camera zooming.
  44467. * A negative number will reverse the axis direction.
  44468. */
  44469. pinchPrecision: number;
  44470. /**
  44471. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44472. * from 0.
  44473. * It defines the percentage of current camera.radius to use as delta when
  44474. * pinch zoom is used.
  44475. */
  44476. pinchDeltaPercentage: number;
  44477. /**
  44478. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44479. */
  44480. axisXControlRadius: boolean;
  44481. /**
  44482. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44483. */
  44484. axisXControlHeight: boolean;
  44485. /**
  44486. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44487. */
  44488. axisXControlRotation: boolean;
  44489. /**
  44490. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44491. */
  44492. axisYControlRadius: boolean;
  44493. /**
  44494. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44495. */
  44496. axisYControlHeight: boolean;
  44497. /**
  44498. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44499. */
  44500. axisYControlRotation: boolean;
  44501. /**
  44502. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44503. */
  44504. axisPinchControlRadius: boolean;
  44505. /**
  44506. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44507. */
  44508. axisPinchControlHeight: boolean;
  44509. /**
  44510. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44511. */
  44512. axisPinchControlRotation: boolean;
  44513. /**
  44514. * Log error messages if basic misconfiguration has occurred.
  44515. */
  44516. warningEnable: boolean;
  44517. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44518. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44519. private _warningCounter;
  44520. private _warning;
  44521. }
  44522. }
  44523. declare module BABYLON {
  44524. /**
  44525. * Default Inputs manager for the FollowCamera.
  44526. * It groups all the default supported inputs for ease of use.
  44527. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44528. */
  44529. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44530. /**
  44531. * Instantiates a new FollowCameraInputsManager.
  44532. * @param camera Defines the camera the inputs belong to
  44533. */
  44534. constructor(camera: FollowCamera);
  44535. /**
  44536. * Add keyboard input support to the input manager.
  44537. * @returns the current input manager
  44538. */
  44539. addKeyboard(): FollowCameraInputsManager;
  44540. /**
  44541. * Add mouse wheel input support to the input manager.
  44542. * @returns the current input manager
  44543. */
  44544. addMouseWheel(): FollowCameraInputsManager;
  44545. /**
  44546. * Add pointers input support to the input manager.
  44547. * @returns the current input manager
  44548. */
  44549. addPointers(): FollowCameraInputsManager;
  44550. /**
  44551. * Add orientation input support to the input manager.
  44552. * @returns the current input manager
  44553. */
  44554. addVRDeviceOrientation(): FollowCameraInputsManager;
  44555. }
  44556. }
  44557. declare module BABYLON {
  44558. /**
  44559. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44560. * an arc rotate version arcFollowCamera are available.
  44561. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44562. */
  44563. export class FollowCamera extends TargetCamera {
  44564. /**
  44565. * Distance the follow camera should follow an object at
  44566. */
  44567. radius: number;
  44568. /**
  44569. * Minimum allowed distance of the camera to the axis of rotation
  44570. * (The camera can not get closer).
  44571. * This can help limiting how the Camera is able to move in the scene.
  44572. */
  44573. lowerRadiusLimit: Nullable<number>;
  44574. /**
  44575. * Maximum allowed distance of the camera to the axis of rotation
  44576. * (The camera can not get further).
  44577. * This can help limiting how the Camera is able to move in the scene.
  44578. */
  44579. upperRadiusLimit: Nullable<number>;
  44580. /**
  44581. * Define a rotation offset between the camera and the object it follows
  44582. */
  44583. rotationOffset: number;
  44584. /**
  44585. * Minimum allowed angle to camera position relative to target object.
  44586. * This can help limiting how the Camera is able to move in the scene.
  44587. */
  44588. lowerRotationOffsetLimit: Nullable<number>;
  44589. /**
  44590. * Maximum allowed angle to camera position relative to target object.
  44591. * This can help limiting how the Camera is able to move in the scene.
  44592. */
  44593. upperRotationOffsetLimit: Nullable<number>;
  44594. /**
  44595. * Define a height offset between the camera and the object it follows.
  44596. * It can help following an object from the top (like a car chaing a plane)
  44597. */
  44598. heightOffset: number;
  44599. /**
  44600. * Minimum allowed height of camera position relative to target object.
  44601. * This can help limiting how the Camera is able to move in the scene.
  44602. */
  44603. lowerHeightOffsetLimit: Nullable<number>;
  44604. /**
  44605. * Maximum allowed height of camera position relative to target object.
  44606. * This can help limiting how the Camera is able to move in the scene.
  44607. */
  44608. upperHeightOffsetLimit: Nullable<number>;
  44609. /**
  44610. * Define how fast the camera can accelerate to follow it s target.
  44611. */
  44612. cameraAcceleration: number;
  44613. /**
  44614. * Define the speed limit of the camera following an object.
  44615. */
  44616. maxCameraSpeed: number;
  44617. /**
  44618. * Define the target of the camera.
  44619. */
  44620. lockedTarget: Nullable<AbstractMesh>;
  44621. /**
  44622. * Defines the input associated with the camera.
  44623. */
  44624. inputs: FollowCameraInputsManager;
  44625. /**
  44626. * Instantiates the follow camera.
  44627. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44628. * @param name Define the name of the camera in the scene
  44629. * @param position Define the position of the camera
  44630. * @param scene Define the scene the camera belong to
  44631. * @param lockedTarget Define the target of the camera
  44632. */
  44633. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44634. private _follow;
  44635. /**
  44636. * Attached controls to the current camera.
  44637. * @param element Defines the element the controls should be listened from
  44638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44639. */
  44640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44641. /**
  44642. * Detach the current controls from the camera.
  44643. * The camera will stop reacting to inputs.
  44644. * @param element Defines the element to stop listening the inputs from
  44645. */
  44646. detachControl(element: HTMLElement): void;
  44647. /** @hidden */
  44648. _checkInputs(): void;
  44649. private _checkLimits;
  44650. /**
  44651. * Gets the camera class name.
  44652. * @returns the class name
  44653. */
  44654. getClassName(): string;
  44655. }
  44656. /**
  44657. * Arc Rotate version of the follow camera.
  44658. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44659. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44660. */
  44661. export class ArcFollowCamera extends TargetCamera {
  44662. /** The longitudinal angle of the camera */
  44663. alpha: number;
  44664. /** The latitudinal angle of the camera */
  44665. beta: number;
  44666. /** The radius of the camera from its target */
  44667. radius: number;
  44668. private _cartesianCoordinates;
  44669. /** Define the camera target (the mesh it should follow) */
  44670. private _meshTarget;
  44671. /**
  44672. * Instantiates a new ArcFollowCamera
  44673. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44674. * @param name Define the name of the camera
  44675. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44676. * @param beta Define the rotation angle of the camera around the elevation axis
  44677. * @param radius Define the radius of the camera from its target point
  44678. * @param target Define the target of the camera
  44679. * @param scene Define the scene the camera belongs to
  44680. */
  44681. constructor(name: string,
  44682. /** The longitudinal angle of the camera */
  44683. alpha: number,
  44684. /** The latitudinal angle of the camera */
  44685. beta: number,
  44686. /** The radius of the camera from its target */
  44687. radius: number,
  44688. /** Define the camera target (the mesh it should follow) */
  44689. target: Nullable<AbstractMesh>, scene: Scene);
  44690. private _follow;
  44691. /** @hidden */
  44692. _checkInputs(): void;
  44693. /**
  44694. * Returns the class name of the object.
  44695. * It is mostly used internally for serialization purposes.
  44696. */
  44697. getClassName(): string;
  44698. }
  44699. }
  44700. declare module BABYLON {
  44701. /**
  44702. * Manage the keyboard inputs to control the movement of a follow camera.
  44703. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44704. */
  44705. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44706. /**
  44707. * Defines the camera the input is attached to.
  44708. */
  44709. camera: FollowCamera;
  44710. /**
  44711. * Defines the list of key codes associated with the up action (increase heightOffset)
  44712. */
  44713. keysHeightOffsetIncr: number[];
  44714. /**
  44715. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44716. */
  44717. keysHeightOffsetDecr: number[];
  44718. /**
  44719. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44720. */
  44721. keysHeightOffsetModifierAlt: boolean;
  44722. /**
  44723. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44724. */
  44725. keysHeightOffsetModifierCtrl: boolean;
  44726. /**
  44727. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44728. */
  44729. keysHeightOffsetModifierShift: boolean;
  44730. /**
  44731. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44732. */
  44733. keysRotationOffsetIncr: number[];
  44734. /**
  44735. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44736. */
  44737. keysRotationOffsetDecr: number[];
  44738. /**
  44739. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44740. */
  44741. keysRotationOffsetModifierAlt: boolean;
  44742. /**
  44743. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44744. */
  44745. keysRotationOffsetModifierCtrl: boolean;
  44746. /**
  44747. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44748. */
  44749. keysRotationOffsetModifierShift: boolean;
  44750. /**
  44751. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44752. */
  44753. keysRadiusIncr: number[];
  44754. /**
  44755. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44756. */
  44757. keysRadiusDecr: number[];
  44758. /**
  44759. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44760. */
  44761. keysRadiusModifierAlt: boolean;
  44762. /**
  44763. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44764. */
  44765. keysRadiusModifierCtrl: boolean;
  44766. /**
  44767. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44768. */
  44769. keysRadiusModifierShift: boolean;
  44770. /**
  44771. * Defines the rate of change of heightOffset.
  44772. */
  44773. heightSensibility: number;
  44774. /**
  44775. * Defines the rate of change of rotationOffset.
  44776. */
  44777. rotationSensibility: number;
  44778. /**
  44779. * Defines the rate of change of radius.
  44780. */
  44781. radiusSensibility: number;
  44782. private _keys;
  44783. private _ctrlPressed;
  44784. private _altPressed;
  44785. private _shiftPressed;
  44786. private _onCanvasBlurObserver;
  44787. private _onKeyboardObserver;
  44788. private _engine;
  44789. private _scene;
  44790. /**
  44791. * Attach the input controls to a specific dom element to get the input from.
  44792. * @param element Defines the element the controls should be listened from
  44793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44794. */
  44795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44796. /**
  44797. * Detach the current controls from the specified dom element.
  44798. * @param element Defines the element to stop listening the inputs from
  44799. */
  44800. detachControl(element: Nullable<HTMLElement>): void;
  44801. /**
  44802. * Update the current camera state depending on the inputs that have been used this frame.
  44803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44804. */
  44805. checkInputs(): void;
  44806. /**
  44807. * Gets the class name of the current input.
  44808. * @returns the class name
  44809. */
  44810. getClassName(): string;
  44811. /**
  44812. * Get the friendly name associated with the input class.
  44813. * @returns the input friendly name
  44814. */
  44815. getSimpleName(): string;
  44816. /**
  44817. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44818. * allow modification of the heightOffset value.
  44819. */
  44820. private _modifierHeightOffset;
  44821. /**
  44822. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44823. * allow modification of the rotationOffset value.
  44824. */
  44825. private _modifierRotationOffset;
  44826. /**
  44827. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44828. * allow modification of the radius value.
  44829. */
  44830. private _modifierRadius;
  44831. }
  44832. }
  44833. declare module BABYLON {
  44834. interface FreeCameraInputsManager {
  44835. /**
  44836. * @hidden
  44837. */
  44838. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44839. /**
  44840. * Add orientation input support to the input manager.
  44841. * @returns the current input manager
  44842. */
  44843. addDeviceOrientation(): FreeCameraInputsManager;
  44844. }
  44845. /**
  44846. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44847. * Screen rotation is taken into account.
  44848. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44849. */
  44850. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44851. private _camera;
  44852. private _screenOrientationAngle;
  44853. private _constantTranform;
  44854. private _screenQuaternion;
  44855. private _alpha;
  44856. private _beta;
  44857. private _gamma;
  44858. /**
  44859. * Can be used to detect if a device orientation sensor is available on a device
  44860. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44861. * @returns a promise that will resolve on orientation change
  44862. */
  44863. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44864. /**
  44865. * @hidden
  44866. */
  44867. _onDeviceOrientationChangedObservable: Observable<void>;
  44868. /**
  44869. * Instantiates a new input
  44870. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44871. */
  44872. constructor();
  44873. /**
  44874. * Define the camera controlled by the input.
  44875. */
  44876. get camera(): FreeCamera;
  44877. set camera(camera: FreeCamera);
  44878. /**
  44879. * Attach the input controls to a specific dom element to get the input from.
  44880. * @param element Defines the element the controls should be listened from
  44881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44882. */
  44883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44884. private _orientationChanged;
  44885. private _deviceOrientation;
  44886. /**
  44887. * Detach the current controls from the specified dom element.
  44888. * @param element Defines the element to stop listening the inputs from
  44889. */
  44890. detachControl(element: Nullable<HTMLElement>): void;
  44891. /**
  44892. * Update the current camera state depending on the inputs that have been used this frame.
  44893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44894. */
  44895. checkInputs(): void;
  44896. /**
  44897. * Gets the class name of the current intput.
  44898. * @returns the class name
  44899. */
  44900. getClassName(): string;
  44901. /**
  44902. * Get the friendly name associated with the input class.
  44903. * @returns the input friendly name
  44904. */
  44905. getSimpleName(): string;
  44906. }
  44907. }
  44908. declare module BABYLON {
  44909. /**
  44910. * Manage the gamepad inputs to control a free camera.
  44911. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44912. */
  44913. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44914. /**
  44915. * Define the camera the input is attached to.
  44916. */
  44917. camera: FreeCamera;
  44918. /**
  44919. * Define the Gamepad controlling the input
  44920. */
  44921. gamepad: Nullable<Gamepad>;
  44922. /**
  44923. * Defines the gamepad rotation sensiblity.
  44924. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44925. */
  44926. gamepadAngularSensibility: number;
  44927. /**
  44928. * Defines the gamepad move sensiblity.
  44929. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44930. */
  44931. gamepadMoveSensibility: number;
  44932. private _yAxisScale;
  44933. /**
  44934. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44935. */
  44936. get invertYAxis(): boolean;
  44937. set invertYAxis(value: boolean);
  44938. private _onGamepadConnectedObserver;
  44939. private _onGamepadDisconnectedObserver;
  44940. private _cameraTransform;
  44941. private _deltaTransform;
  44942. private _vector3;
  44943. private _vector2;
  44944. /**
  44945. * Attach the input controls to a specific dom element to get the input from.
  44946. * @param element Defines the element the controls should be listened from
  44947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44948. */
  44949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44950. /**
  44951. * Detach the current controls from the specified dom element.
  44952. * @param element Defines the element to stop listening the inputs from
  44953. */
  44954. detachControl(element: Nullable<HTMLElement>): void;
  44955. /**
  44956. * Update the current camera state depending on the inputs that have been used this frame.
  44957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44958. */
  44959. checkInputs(): void;
  44960. /**
  44961. * Gets the class name of the current intput.
  44962. * @returns the class name
  44963. */
  44964. getClassName(): string;
  44965. /**
  44966. * Get the friendly name associated with the input class.
  44967. * @returns the input friendly name
  44968. */
  44969. getSimpleName(): string;
  44970. }
  44971. }
  44972. declare module BABYLON {
  44973. /**
  44974. * Defines the potential axis of a Joystick
  44975. */
  44976. export enum JoystickAxis {
  44977. /** X axis */
  44978. X = 0,
  44979. /** Y axis */
  44980. Y = 1,
  44981. /** Z axis */
  44982. Z = 2
  44983. }
  44984. /**
  44985. * Represents the different customization options available
  44986. * for VirtualJoystick
  44987. */
  44988. interface VirtualJoystickCustomizations {
  44989. /**
  44990. * Size of the joystick's puck
  44991. */
  44992. puckSize: number;
  44993. /**
  44994. * Size of the joystick's container
  44995. */
  44996. containerSize: number;
  44997. /**
  44998. * Color of the joystick && puck
  44999. */
  45000. color: string;
  45001. /**
  45002. * Image URL for the joystick's puck
  45003. */
  45004. puckImage?: string;
  45005. /**
  45006. * Image URL for the joystick's container
  45007. */
  45008. containerImage?: string;
  45009. /**
  45010. * Defines the unmoving position of the joystick container
  45011. */
  45012. position?: {
  45013. x: number;
  45014. y: number;
  45015. };
  45016. /**
  45017. * Defines whether or not the joystick container is always visible
  45018. */
  45019. alwaysVisible: boolean;
  45020. /**
  45021. * Defines whether or not to limit the movement of the puck to the joystick's container
  45022. */
  45023. limitToContainer: boolean;
  45024. }
  45025. /**
  45026. * Class used to define virtual joystick (used in touch mode)
  45027. */
  45028. export class VirtualJoystick {
  45029. /**
  45030. * Gets or sets a boolean indicating that left and right values must be inverted
  45031. */
  45032. reverseLeftRight: boolean;
  45033. /**
  45034. * Gets or sets a boolean indicating that up and down values must be inverted
  45035. */
  45036. reverseUpDown: boolean;
  45037. /**
  45038. * Gets the offset value for the position (ie. the change of the position value)
  45039. */
  45040. deltaPosition: Vector3;
  45041. /**
  45042. * Gets a boolean indicating if the virtual joystick was pressed
  45043. */
  45044. pressed: boolean;
  45045. /**
  45046. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45047. */
  45048. static Canvas: Nullable<HTMLCanvasElement>;
  45049. /**
  45050. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45051. */
  45052. limitToContainer: boolean;
  45053. private static _globalJoystickIndex;
  45054. private static _alwaysVisibleSticks;
  45055. private static vjCanvasContext;
  45056. private static vjCanvasWidth;
  45057. private static vjCanvasHeight;
  45058. private static halfWidth;
  45059. private static _GetDefaultOptions;
  45060. private _action;
  45061. private _axisTargetedByLeftAndRight;
  45062. private _axisTargetedByUpAndDown;
  45063. private _joystickSensibility;
  45064. private _inversedSensibility;
  45065. private _joystickPointerID;
  45066. private _joystickColor;
  45067. private _joystickPointerPos;
  45068. private _joystickPreviousPointerPos;
  45069. private _joystickPointerStartPos;
  45070. private _deltaJoystickVector;
  45071. private _leftJoystick;
  45072. private _touches;
  45073. private _joystickPosition;
  45074. private _alwaysVisible;
  45075. private _puckImage;
  45076. private _containerImage;
  45077. private _joystickPuckSize;
  45078. private _joystickContainerSize;
  45079. private _clearPuckSize;
  45080. private _clearContainerSize;
  45081. private _clearPuckSizeOffset;
  45082. private _clearContainerSizeOffset;
  45083. private _onPointerDownHandlerRef;
  45084. private _onPointerMoveHandlerRef;
  45085. private _onPointerUpHandlerRef;
  45086. private _onResize;
  45087. /**
  45088. * Creates a new virtual joystick
  45089. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45090. * @param customizations Defines the options we want to customize the VirtualJoystick
  45091. */
  45092. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45093. /**
  45094. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45095. * @param newJoystickSensibility defines the new sensibility
  45096. */
  45097. setJoystickSensibility(newJoystickSensibility: number): void;
  45098. private _onPointerDown;
  45099. private _onPointerMove;
  45100. private _onPointerUp;
  45101. /**
  45102. * Change the color of the virtual joystick
  45103. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45104. */
  45105. setJoystickColor(newColor: string): void;
  45106. /**
  45107. * Size of the joystick's container
  45108. */
  45109. set containerSize(newSize: number);
  45110. get containerSize(): number;
  45111. /**
  45112. * Size of the joystick's puck
  45113. */
  45114. set puckSize(newSize: number);
  45115. get puckSize(): number;
  45116. /**
  45117. * Clears the set position of the joystick
  45118. */
  45119. clearPosition(): void;
  45120. /**
  45121. * Defines whether or not the joystick container is always visible
  45122. */
  45123. set alwaysVisible(value: boolean);
  45124. get alwaysVisible(): boolean;
  45125. /**
  45126. * Sets the constant position of the Joystick container
  45127. * @param x X axis coordinate
  45128. * @param y Y axis coordinate
  45129. */
  45130. setPosition(x: number, y: number): void;
  45131. /**
  45132. * Defines a callback to call when the joystick is touched
  45133. * @param action defines the callback
  45134. */
  45135. setActionOnTouch(action: () => any): void;
  45136. /**
  45137. * Defines which axis you'd like to control for left & right
  45138. * @param axis defines the axis to use
  45139. */
  45140. setAxisForLeftRight(axis: JoystickAxis): void;
  45141. /**
  45142. * Defines which axis you'd like to control for up & down
  45143. * @param axis defines the axis to use
  45144. */
  45145. setAxisForUpDown(axis: JoystickAxis): void;
  45146. /**
  45147. * Clears the canvas from the previous puck / container draw
  45148. */
  45149. private _clearPreviousDraw;
  45150. /**
  45151. * Loads `urlPath` to be used for the container's image
  45152. * @param urlPath defines the urlPath of an image to use
  45153. */
  45154. setContainerImage(urlPath: string): void;
  45155. /**
  45156. * Loads `urlPath` to be used for the puck's image
  45157. * @param urlPath defines the urlPath of an image to use
  45158. */
  45159. setPuckImage(urlPath: string): void;
  45160. /**
  45161. * Draws the Virtual Joystick's container
  45162. */
  45163. private _drawContainer;
  45164. /**
  45165. * Draws the Virtual Joystick's puck
  45166. */
  45167. private _drawPuck;
  45168. private _drawVirtualJoystick;
  45169. /**
  45170. * Release internal HTML canvas
  45171. */
  45172. releaseCanvas(): void;
  45173. }
  45174. }
  45175. declare module BABYLON {
  45176. interface FreeCameraInputsManager {
  45177. /**
  45178. * Add virtual joystick input support to the input manager.
  45179. * @returns the current input manager
  45180. */
  45181. addVirtualJoystick(): FreeCameraInputsManager;
  45182. }
  45183. /**
  45184. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45185. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45186. */
  45187. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45188. /**
  45189. * Defines the camera the input is attached to.
  45190. */
  45191. camera: FreeCamera;
  45192. private _leftjoystick;
  45193. private _rightjoystick;
  45194. /**
  45195. * Gets the left stick of the virtual joystick.
  45196. * @returns The virtual Joystick
  45197. */
  45198. getLeftJoystick(): VirtualJoystick;
  45199. /**
  45200. * Gets the right stick of the virtual joystick.
  45201. * @returns The virtual Joystick
  45202. */
  45203. getRightJoystick(): VirtualJoystick;
  45204. /**
  45205. * Update the current camera state depending on the inputs that have been used this frame.
  45206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45207. */
  45208. checkInputs(): void;
  45209. /**
  45210. * Attach the input controls to a specific dom element to get the input from.
  45211. * @param element Defines the element the controls should be listened from
  45212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45213. */
  45214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45215. /**
  45216. * Detach the current controls from the specified dom element.
  45217. * @param element Defines the element to stop listening the inputs from
  45218. */
  45219. detachControl(element: Nullable<HTMLElement>): void;
  45220. /**
  45221. * Gets the class name of the current intput.
  45222. * @returns the class name
  45223. */
  45224. getClassName(): string;
  45225. /**
  45226. * Get the friendly name associated with the input class.
  45227. * @returns the input friendly name
  45228. */
  45229. getSimpleName(): string;
  45230. }
  45231. }
  45232. declare module BABYLON {
  45233. /**
  45234. * This represents a FPS type of camera controlled by touch.
  45235. * This is like a universal camera minus the Gamepad controls.
  45236. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45237. */
  45238. export class TouchCamera extends FreeCamera {
  45239. /**
  45240. * Defines the touch sensibility for rotation.
  45241. * The higher the faster.
  45242. */
  45243. get touchAngularSensibility(): number;
  45244. set touchAngularSensibility(value: number);
  45245. /**
  45246. * Defines the touch sensibility for move.
  45247. * The higher the faster.
  45248. */
  45249. get touchMoveSensibility(): number;
  45250. set touchMoveSensibility(value: number);
  45251. /**
  45252. * Instantiates a new touch camera.
  45253. * This represents a FPS type of camera controlled by touch.
  45254. * This is like a universal camera minus the Gamepad controls.
  45255. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45256. * @param name Define the name of the camera in the scene
  45257. * @param position Define the start position of the camera in the scene
  45258. * @param scene Define the scene the camera belongs to
  45259. */
  45260. constructor(name: string, position: Vector3, scene: Scene);
  45261. /**
  45262. * Gets the current object class name.
  45263. * @return the class name
  45264. */
  45265. getClassName(): string;
  45266. /** @hidden */
  45267. _setupInputs(): void;
  45268. }
  45269. }
  45270. declare module BABYLON {
  45271. /**
  45272. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45273. * being tilted forward or back and left or right.
  45274. */
  45275. export class DeviceOrientationCamera extends FreeCamera {
  45276. private _initialQuaternion;
  45277. private _quaternionCache;
  45278. private _tmpDragQuaternion;
  45279. private _disablePointerInputWhenUsingDeviceOrientation;
  45280. /**
  45281. * Creates a new device orientation camera
  45282. * @param name The name of the camera
  45283. * @param position The start position camera
  45284. * @param scene The scene the camera belongs to
  45285. */
  45286. constructor(name: string, position: Vector3, scene: Scene);
  45287. /**
  45288. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45289. */
  45290. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45291. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45292. private _dragFactor;
  45293. /**
  45294. * Enabled turning on the y axis when the orientation sensor is active
  45295. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45296. */
  45297. enableHorizontalDragging(dragFactor?: number): void;
  45298. /**
  45299. * Gets the current instance class name ("DeviceOrientationCamera").
  45300. * This helps avoiding instanceof at run time.
  45301. * @returns the class name
  45302. */
  45303. getClassName(): string;
  45304. /**
  45305. * @hidden
  45306. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45307. */
  45308. _checkInputs(): void;
  45309. /**
  45310. * Reset the camera to its default orientation on the specified axis only.
  45311. * @param axis The axis to reset
  45312. */
  45313. resetToCurrentRotation(axis?: Axis): void;
  45314. }
  45315. }
  45316. declare module BABYLON {
  45317. /**
  45318. * Defines supported buttons for XBox360 compatible gamepads
  45319. */
  45320. export enum Xbox360Button {
  45321. /** A */
  45322. A = 0,
  45323. /** B */
  45324. B = 1,
  45325. /** X */
  45326. X = 2,
  45327. /** Y */
  45328. Y = 3,
  45329. /** Left button */
  45330. LB = 4,
  45331. /** Right button */
  45332. RB = 5,
  45333. /** Back */
  45334. Back = 8,
  45335. /** Start */
  45336. Start = 9,
  45337. /** Left stick */
  45338. LeftStick = 10,
  45339. /** Right stick */
  45340. RightStick = 11
  45341. }
  45342. /** Defines values for XBox360 DPad */
  45343. export enum Xbox360Dpad {
  45344. /** Up */
  45345. Up = 12,
  45346. /** Down */
  45347. Down = 13,
  45348. /** Left */
  45349. Left = 14,
  45350. /** Right */
  45351. Right = 15
  45352. }
  45353. /**
  45354. * Defines a XBox360 gamepad
  45355. */
  45356. export class Xbox360Pad extends Gamepad {
  45357. private _leftTrigger;
  45358. private _rightTrigger;
  45359. private _onlefttriggerchanged;
  45360. private _onrighttriggerchanged;
  45361. private _onbuttondown;
  45362. private _onbuttonup;
  45363. private _ondpaddown;
  45364. private _ondpadup;
  45365. /** Observable raised when a button is pressed */
  45366. onButtonDownObservable: Observable<Xbox360Button>;
  45367. /** Observable raised when a button is released */
  45368. onButtonUpObservable: Observable<Xbox360Button>;
  45369. /** Observable raised when a pad is pressed */
  45370. onPadDownObservable: Observable<Xbox360Dpad>;
  45371. /** Observable raised when a pad is released */
  45372. onPadUpObservable: Observable<Xbox360Dpad>;
  45373. private _buttonA;
  45374. private _buttonB;
  45375. private _buttonX;
  45376. private _buttonY;
  45377. private _buttonBack;
  45378. private _buttonStart;
  45379. private _buttonLB;
  45380. private _buttonRB;
  45381. private _buttonLeftStick;
  45382. private _buttonRightStick;
  45383. private _dPadUp;
  45384. private _dPadDown;
  45385. private _dPadLeft;
  45386. private _dPadRight;
  45387. private _isXboxOnePad;
  45388. /**
  45389. * Creates a new XBox360 gamepad object
  45390. * @param id defines the id of this gamepad
  45391. * @param index defines its index
  45392. * @param gamepad defines the internal HTML gamepad object
  45393. * @param xboxOne defines if it is a XBox One gamepad
  45394. */
  45395. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45396. /**
  45397. * Defines the callback to call when left trigger is pressed
  45398. * @param callback defines the callback to use
  45399. */
  45400. onlefttriggerchanged(callback: (value: number) => void): void;
  45401. /**
  45402. * Defines the callback to call when right trigger is pressed
  45403. * @param callback defines the callback to use
  45404. */
  45405. onrighttriggerchanged(callback: (value: number) => void): void;
  45406. /**
  45407. * Gets the left trigger value
  45408. */
  45409. get leftTrigger(): number;
  45410. /**
  45411. * Sets the left trigger value
  45412. */
  45413. set leftTrigger(newValue: number);
  45414. /**
  45415. * Gets the right trigger value
  45416. */
  45417. get rightTrigger(): number;
  45418. /**
  45419. * Sets the right trigger value
  45420. */
  45421. set rightTrigger(newValue: number);
  45422. /**
  45423. * Defines the callback to call when a button is pressed
  45424. * @param callback defines the callback to use
  45425. */
  45426. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45427. /**
  45428. * Defines the callback to call when a button is released
  45429. * @param callback defines the callback to use
  45430. */
  45431. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45432. /**
  45433. * Defines the callback to call when a pad is pressed
  45434. * @param callback defines the callback to use
  45435. */
  45436. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45437. /**
  45438. * Defines the callback to call when a pad is released
  45439. * @param callback defines the callback to use
  45440. */
  45441. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45442. private _setButtonValue;
  45443. private _setDPadValue;
  45444. /**
  45445. * Gets the value of the `A` button
  45446. */
  45447. get buttonA(): number;
  45448. /**
  45449. * Sets the value of the `A` button
  45450. */
  45451. set buttonA(value: number);
  45452. /**
  45453. * Gets the value of the `B` button
  45454. */
  45455. get buttonB(): number;
  45456. /**
  45457. * Sets the value of the `B` button
  45458. */
  45459. set buttonB(value: number);
  45460. /**
  45461. * Gets the value of the `X` button
  45462. */
  45463. get buttonX(): number;
  45464. /**
  45465. * Sets the value of the `X` button
  45466. */
  45467. set buttonX(value: number);
  45468. /**
  45469. * Gets the value of the `Y` button
  45470. */
  45471. get buttonY(): number;
  45472. /**
  45473. * Sets the value of the `Y` button
  45474. */
  45475. set buttonY(value: number);
  45476. /**
  45477. * Gets the value of the `Start` button
  45478. */
  45479. get buttonStart(): number;
  45480. /**
  45481. * Sets the value of the `Start` button
  45482. */
  45483. set buttonStart(value: number);
  45484. /**
  45485. * Gets the value of the `Back` button
  45486. */
  45487. get buttonBack(): number;
  45488. /**
  45489. * Sets the value of the `Back` button
  45490. */
  45491. set buttonBack(value: number);
  45492. /**
  45493. * Gets the value of the `Left` button
  45494. */
  45495. get buttonLB(): number;
  45496. /**
  45497. * Sets the value of the `Left` button
  45498. */
  45499. set buttonLB(value: number);
  45500. /**
  45501. * Gets the value of the `Right` button
  45502. */
  45503. get buttonRB(): number;
  45504. /**
  45505. * Sets the value of the `Right` button
  45506. */
  45507. set buttonRB(value: number);
  45508. /**
  45509. * Gets the value of the Left joystick
  45510. */
  45511. get buttonLeftStick(): number;
  45512. /**
  45513. * Sets the value of the Left joystick
  45514. */
  45515. set buttonLeftStick(value: number);
  45516. /**
  45517. * Gets the value of the Right joystick
  45518. */
  45519. get buttonRightStick(): number;
  45520. /**
  45521. * Sets the value of the Right joystick
  45522. */
  45523. set buttonRightStick(value: number);
  45524. /**
  45525. * Gets the value of D-pad up
  45526. */
  45527. get dPadUp(): number;
  45528. /**
  45529. * Sets the value of D-pad up
  45530. */
  45531. set dPadUp(value: number);
  45532. /**
  45533. * Gets the value of D-pad down
  45534. */
  45535. get dPadDown(): number;
  45536. /**
  45537. * Sets the value of D-pad down
  45538. */
  45539. set dPadDown(value: number);
  45540. /**
  45541. * Gets the value of D-pad left
  45542. */
  45543. get dPadLeft(): number;
  45544. /**
  45545. * Sets the value of D-pad left
  45546. */
  45547. set dPadLeft(value: number);
  45548. /**
  45549. * Gets the value of D-pad right
  45550. */
  45551. get dPadRight(): number;
  45552. /**
  45553. * Sets the value of D-pad right
  45554. */
  45555. set dPadRight(value: number);
  45556. /**
  45557. * Force the gamepad to synchronize with device values
  45558. */
  45559. update(): void;
  45560. /**
  45561. * Disposes the gamepad
  45562. */
  45563. dispose(): void;
  45564. }
  45565. }
  45566. declare module BABYLON {
  45567. /**
  45568. * Defines supported buttons for DualShock compatible gamepads
  45569. */
  45570. export enum DualShockButton {
  45571. /** Cross */
  45572. Cross = 0,
  45573. /** Circle */
  45574. Circle = 1,
  45575. /** Square */
  45576. Square = 2,
  45577. /** Triangle */
  45578. Triangle = 3,
  45579. /** L1 */
  45580. L1 = 4,
  45581. /** R1 */
  45582. R1 = 5,
  45583. /** Share */
  45584. Share = 8,
  45585. /** Options */
  45586. Options = 9,
  45587. /** Left stick */
  45588. LeftStick = 10,
  45589. /** Right stick */
  45590. RightStick = 11
  45591. }
  45592. /** Defines values for DualShock DPad */
  45593. export enum DualShockDpad {
  45594. /** Up */
  45595. Up = 12,
  45596. /** Down */
  45597. Down = 13,
  45598. /** Left */
  45599. Left = 14,
  45600. /** Right */
  45601. Right = 15
  45602. }
  45603. /**
  45604. * Defines a DualShock gamepad
  45605. */
  45606. export class DualShockPad extends Gamepad {
  45607. private _leftTrigger;
  45608. private _rightTrigger;
  45609. private _onlefttriggerchanged;
  45610. private _onrighttriggerchanged;
  45611. private _onbuttondown;
  45612. private _onbuttonup;
  45613. private _ondpaddown;
  45614. private _ondpadup;
  45615. /** Observable raised when a button is pressed */
  45616. onButtonDownObservable: Observable<DualShockButton>;
  45617. /** Observable raised when a button is released */
  45618. onButtonUpObservable: Observable<DualShockButton>;
  45619. /** Observable raised when a pad is pressed */
  45620. onPadDownObservable: Observable<DualShockDpad>;
  45621. /** Observable raised when a pad is released */
  45622. onPadUpObservable: Observable<DualShockDpad>;
  45623. private _buttonCross;
  45624. private _buttonCircle;
  45625. private _buttonSquare;
  45626. private _buttonTriangle;
  45627. private _buttonShare;
  45628. private _buttonOptions;
  45629. private _buttonL1;
  45630. private _buttonR1;
  45631. private _buttonLeftStick;
  45632. private _buttonRightStick;
  45633. private _dPadUp;
  45634. private _dPadDown;
  45635. private _dPadLeft;
  45636. private _dPadRight;
  45637. /**
  45638. * Creates a new DualShock gamepad object
  45639. * @param id defines the id of this gamepad
  45640. * @param index defines its index
  45641. * @param gamepad defines the internal HTML gamepad object
  45642. */
  45643. constructor(id: string, index: number, gamepad: any);
  45644. /**
  45645. * Defines the callback to call when left trigger is pressed
  45646. * @param callback defines the callback to use
  45647. */
  45648. onlefttriggerchanged(callback: (value: number) => void): void;
  45649. /**
  45650. * Defines the callback to call when right trigger is pressed
  45651. * @param callback defines the callback to use
  45652. */
  45653. onrighttriggerchanged(callback: (value: number) => void): void;
  45654. /**
  45655. * Gets the left trigger value
  45656. */
  45657. get leftTrigger(): number;
  45658. /**
  45659. * Sets the left trigger value
  45660. */
  45661. set leftTrigger(newValue: number);
  45662. /**
  45663. * Gets the right trigger value
  45664. */
  45665. get rightTrigger(): number;
  45666. /**
  45667. * Sets the right trigger value
  45668. */
  45669. set rightTrigger(newValue: number);
  45670. /**
  45671. * Defines the callback to call when a button is pressed
  45672. * @param callback defines the callback to use
  45673. */
  45674. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45675. /**
  45676. * Defines the callback to call when a button is released
  45677. * @param callback defines the callback to use
  45678. */
  45679. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45680. /**
  45681. * Defines the callback to call when a pad is pressed
  45682. * @param callback defines the callback to use
  45683. */
  45684. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45685. /**
  45686. * Defines the callback to call when a pad is released
  45687. * @param callback defines the callback to use
  45688. */
  45689. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45690. private _setButtonValue;
  45691. private _setDPadValue;
  45692. /**
  45693. * Gets the value of the `Cross` button
  45694. */
  45695. get buttonCross(): number;
  45696. /**
  45697. * Sets the value of the `Cross` button
  45698. */
  45699. set buttonCross(value: number);
  45700. /**
  45701. * Gets the value of the `Circle` button
  45702. */
  45703. get buttonCircle(): number;
  45704. /**
  45705. * Sets the value of the `Circle` button
  45706. */
  45707. set buttonCircle(value: number);
  45708. /**
  45709. * Gets the value of the `Square` button
  45710. */
  45711. get buttonSquare(): number;
  45712. /**
  45713. * Sets the value of the `Square` button
  45714. */
  45715. set buttonSquare(value: number);
  45716. /**
  45717. * Gets the value of the `Triangle` button
  45718. */
  45719. get buttonTriangle(): number;
  45720. /**
  45721. * Sets the value of the `Triangle` button
  45722. */
  45723. set buttonTriangle(value: number);
  45724. /**
  45725. * Gets the value of the `Options` button
  45726. */
  45727. get buttonOptions(): number;
  45728. /**
  45729. * Sets the value of the `Options` button
  45730. */
  45731. set buttonOptions(value: number);
  45732. /**
  45733. * Gets the value of the `Share` button
  45734. */
  45735. get buttonShare(): number;
  45736. /**
  45737. * Sets the value of the `Share` button
  45738. */
  45739. set buttonShare(value: number);
  45740. /**
  45741. * Gets the value of the `L1` button
  45742. */
  45743. get buttonL1(): number;
  45744. /**
  45745. * Sets the value of the `L1` button
  45746. */
  45747. set buttonL1(value: number);
  45748. /**
  45749. * Gets the value of the `R1` button
  45750. */
  45751. get buttonR1(): number;
  45752. /**
  45753. * Sets the value of the `R1` button
  45754. */
  45755. set buttonR1(value: number);
  45756. /**
  45757. * Gets the value of the Left joystick
  45758. */
  45759. get buttonLeftStick(): number;
  45760. /**
  45761. * Sets the value of the Left joystick
  45762. */
  45763. set buttonLeftStick(value: number);
  45764. /**
  45765. * Gets the value of the Right joystick
  45766. */
  45767. get buttonRightStick(): number;
  45768. /**
  45769. * Sets the value of the Right joystick
  45770. */
  45771. set buttonRightStick(value: number);
  45772. /**
  45773. * Gets the value of D-pad up
  45774. */
  45775. get dPadUp(): number;
  45776. /**
  45777. * Sets the value of D-pad up
  45778. */
  45779. set dPadUp(value: number);
  45780. /**
  45781. * Gets the value of D-pad down
  45782. */
  45783. get dPadDown(): number;
  45784. /**
  45785. * Sets the value of D-pad down
  45786. */
  45787. set dPadDown(value: number);
  45788. /**
  45789. * Gets the value of D-pad left
  45790. */
  45791. get dPadLeft(): number;
  45792. /**
  45793. * Sets the value of D-pad left
  45794. */
  45795. set dPadLeft(value: number);
  45796. /**
  45797. * Gets the value of D-pad right
  45798. */
  45799. get dPadRight(): number;
  45800. /**
  45801. * Sets the value of D-pad right
  45802. */
  45803. set dPadRight(value: number);
  45804. /**
  45805. * Force the gamepad to synchronize with device values
  45806. */
  45807. update(): void;
  45808. /**
  45809. * Disposes the gamepad
  45810. */
  45811. dispose(): void;
  45812. }
  45813. }
  45814. declare module BABYLON {
  45815. /**
  45816. * Manager for handling gamepads
  45817. */
  45818. export class GamepadManager {
  45819. private _scene?;
  45820. private _babylonGamepads;
  45821. private _oneGamepadConnected;
  45822. /** @hidden */
  45823. _isMonitoring: boolean;
  45824. private _gamepadEventSupported;
  45825. private _gamepadSupport?;
  45826. /**
  45827. * observable to be triggered when the gamepad controller has been connected
  45828. */
  45829. onGamepadConnectedObservable: Observable<Gamepad>;
  45830. /**
  45831. * observable to be triggered when the gamepad controller has been disconnected
  45832. */
  45833. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45834. private _onGamepadConnectedEvent;
  45835. private _onGamepadDisconnectedEvent;
  45836. /**
  45837. * Initializes the gamepad manager
  45838. * @param _scene BabylonJS scene
  45839. */
  45840. constructor(_scene?: Scene | undefined);
  45841. /**
  45842. * The gamepads in the game pad manager
  45843. */
  45844. get gamepads(): Gamepad[];
  45845. /**
  45846. * Get the gamepad controllers based on type
  45847. * @param type The type of gamepad controller
  45848. * @returns Nullable gamepad
  45849. */
  45850. getGamepadByType(type?: number): Nullable<Gamepad>;
  45851. /**
  45852. * Disposes the gamepad manager
  45853. */
  45854. dispose(): void;
  45855. private _addNewGamepad;
  45856. private _startMonitoringGamepads;
  45857. private _stopMonitoringGamepads;
  45858. /** @hidden */
  45859. _checkGamepadsStatus(): void;
  45860. private _updateGamepadObjects;
  45861. }
  45862. }
  45863. declare module BABYLON {
  45864. interface Scene {
  45865. /** @hidden */
  45866. _gamepadManager: Nullable<GamepadManager>;
  45867. /**
  45868. * Gets the gamepad manager associated with the scene
  45869. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45870. */
  45871. gamepadManager: GamepadManager;
  45872. }
  45873. /**
  45874. * Interface representing a free camera inputs manager
  45875. */
  45876. interface FreeCameraInputsManager {
  45877. /**
  45878. * Adds gamepad input support to the FreeCameraInputsManager.
  45879. * @returns the FreeCameraInputsManager
  45880. */
  45881. addGamepad(): FreeCameraInputsManager;
  45882. }
  45883. /**
  45884. * Interface representing an arc rotate camera inputs manager
  45885. */
  45886. interface ArcRotateCameraInputsManager {
  45887. /**
  45888. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45889. * @returns the camera inputs manager
  45890. */
  45891. addGamepad(): ArcRotateCameraInputsManager;
  45892. }
  45893. /**
  45894. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45895. */
  45896. export class GamepadSystemSceneComponent implements ISceneComponent {
  45897. /**
  45898. * The component name helpfull to identify the component in the list of scene components.
  45899. */
  45900. readonly name: string;
  45901. /**
  45902. * The scene the component belongs to.
  45903. */
  45904. scene: Scene;
  45905. /**
  45906. * Creates a new instance of the component for the given scene
  45907. * @param scene Defines the scene to register the component in
  45908. */
  45909. constructor(scene: Scene);
  45910. /**
  45911. * Registers the component in a given scene
  45912. */
  45913. register(): void;
  45914. /**
  45915. * Rebuilds the elements related to this component in case of
  45916. * context lost for instance.
  45917. */
  45918. rebuild(): void;
  45919. /**
  45920. * Disposes the component and the associated ressources
  45921. */
  45922. dispose(): void;
  45923. private _beforeCameraUpdate;
  45924. }
  45925. }
  45926. declare module BABYLON {
  45927. /**
  45928. * 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,
  45929. * which still works and will still be found in many Playgrounds.
  45930. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45931. */
  45932. export class UniversalCamera extends TouchCamera {
  45933. /**
  45934. * Defines the gamepad rotation sensiblity.
  45935. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45936. */
  45937. get gamepadAngularSensibility(): number;
  45938. set gamepadAngularSensibility(value: number);
  45939. /**
  45940. * Defines the gamepad move sensiblity.
  45941. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45942. */
  45943. get gamepadMoveSensibility(): number;
  45944. set gamepadMoveSensibility(value: number);
  45945. /**
  45946. * 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,
  45947. * which still works and will still be found in many Playgrounds.
  45948. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45949. * @param name Define the name of the camera in the scene
  45950. * @param position Define the start position of the camera in the scene
  45951. * @param scene Define the scene the camera belongs to
  45952. */
  45953. constructor(name: string, position: Vector3, scene: Scene);
  45954. /**
  45955. * Gets the current object class name.
  45956. * @return the class name
  45957. */
  45958. getClassName(): string;
  45959. }
  45960. }
  45961. declare module BABYLON {
  45962. /**
  45963. * This represents a FPS type of camera. This is only here for back compat purpose.
  45964. * Please use the UniversalCamera instead as both are identical.
  45965. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45966. */
  45967. export class GamepadCamera extends UniversalCamera {
  45968. /**
  45969. * Instantiates a new Gamepad Camera
  45970. * This represents a FPS type of camera. This is only here for back compat purpose.
  45971. * Please use the UniversalCamera instead as both are identical.
  45972. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45973. * @param name Define the name of the camera in the scene
  45974. * @param position Define the start position of the camera in the scene
  45975. * @param scene Define the scene the camera belongs to
  45976. */
  45977. constructor(name: string, position: Vector3, scene: Scene);
  45978. /**
  45979. * Gets the current object class name.
  45980. * @return the class name
  45981. */
  45982. getClassName(): string;
  45983. }
  45984. }
  45985. declare module BABYLON {
  45986. /** @hidden */
  45987. export var passPixelShader: {
  45988. name: string;
  45989. shader: string;
  45990. };
  45991. }
  45992. declare module BABYLON {
  45993. /** @hidden */
  45994. export var passCubePixelShader: {
  45995. name: string;
  45996. shader: string;
  45997. };
  45998. }
  45999. declare module BABYLON {
  46000. /**
  46001. * PassPostProcess which produces an output the same as it's input
  46002. */
  46003. export class PassPostProcess extends PostProcess {
  46004. /**
  46005. * Gets a string identifying the name of the class
  46006. * @returns "PassPostProcess" string
  46007. */
  46008. getClassName(): string;
  46009. /**
  46010. * Creates the PassPostProcess
  46011. * @param name The name of the effect.
  46012. * @param options The required width/height ratio to downsize to before computing the render pass.
  46013. * @param camera The camera to apply the render pass to.
  46014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46015. * @param engine The engine which the post process will be applied. (default: current engine)
  46016. * @param reusable If the post process can be reused on the same frame. (default: false)
  46017. * @param textureType The type of texture to be used when performing the post processing.
  46018. * @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)
  46019. */
  46020. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46021. /** @hidden */
  46022. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46023. }
  46024. /**
  46025. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46026. */
  46027. export class PassCubePostProcess extends PostProcess {
  46028. private _face;
  46029. /**
  46030. * Gets or sets the cube face to display.
  46031. * * 0 is +X
  46032. * * 1 is -X
  46033. * * 2 is +Y
  46034. * * 3 is -Y
  46035. * * 4 is +Z
  46036. * * 5 is -Z
  46037. */
  46038. get face(): number;
  46039. set face(value: number);
  46040. /**
  46041. * Gets a string identifying the name of the class
  46042. * @returns "PassCubePostProcess" string
  46043. */
  46044. getClassName(): string;
  46045. /**
  46046. * Creates the PassCubePostProcess
  46047. * @param name The name of the effect.
  46048. * @param options The required width/height ratio to downsize to before computing the render pass.
  46049. * @param camera The camera to apply the render pass to.
  46050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46051. * @param engine The engine which the post process will be applied. (default: current engine)
  46052. * @param reusable If the post process can be reused on the same frame. (default: false)
  46053. * @param textureType The type of texture to be used when performing the post processing.
  46054. * @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)
  46055. */
  46056. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46057. /** @hidden */
  46058. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46059. }
  46060. }
  46061. declare module BABYLON {
  46062. /** @hidden */
  46063. export var anaglyphPixelShader: {
  46064. name: string;
  46065. shader: string;
  46066. };
  46067. }
  46068. declare module BABYLON {
  46069. /**
  46070. * Postprocess used to generate anaglyphic rendering
  46071. */
  46072. export class AnaglyphPostProcess extends PostProcess {
  46073. private _passedProcess;
  46074. /**
  46075. * Gets a string identifying the name of the class
  46076. * @returns "AnaglyphPostProcess" string
  46077. */
  46078. getClassName(): string;
  46079. /**
  46080. * Creates a new AnaglyphPostProcess
  46081. * @param name defines postprocess name
  46082. * @param options defines creation options or target ratio scale
  46083. * @param rigCameras defines cameras using this postprocess
  46084. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46085. * @param engine defines hosting engine
  46086. * @param reusable defines if the postprocess will be reused multiple times per frame
  46087. */
  46088. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46089. }
  46090. }
  46091. declare module BABYLON {
  46092. /**
  46093. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46094. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46095. */
  46096. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46097. /**
  46098. * Creates a new AnaglyphArcRotateCamera
  46099. * @param name defines camera name
  46100. * @param alpha defines alpha angle (in radians)
  46101. * @param beta defines beta angle (in radians)
  46102. * @param radius defines radius
  46103. * @param target defines camera target
  46104. * @param interaxialDistance defines distance between each color axis
  46105. * @param scene defines the hosting scene
  46106. */
  46107. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46108. /**
  46109. * Gets camera class name
  46110. * @returns AnaglyphArcRotateCamera
  46111. */
  46112. getClassName(): string;
  46113. }
  46114. }
  46115. declare module BABYLON {
  46116. /**
  46117. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46118. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46119. */
  46120. export class AnaglyphFreeCamera extends FreeCamera {
  46121. /**
  46122. * Creates a new AnaglyphFreeCamera
  46123. * @param name defines camera name
  46124. * @param position defines initial position
  46125. * @param interaxialDistance defines distance between each color axis
  46126. * @param scene defines the hosting scene
  46127. */
  46128. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46129. /**
  46130. * Gets camera class name
  46131. * @returns AnaglyphFreeCamera
  46132. */
  46133. getClassName(): string;
  46134. }
  46135. }
  46136. declare module BABYLON {
  46137. /**
  46138. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46139. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46140. */
  46141. export class AnaglyphGamepadCamera extends GamepadCamera {
  46142. /**
  46143. * Creates a new AnaglyphGamepadCamera
  46144. * @param name defines camera name
  46145. * @param position defines initial position
  46146. * @param interaxialDistance defines distance between each color axis
  46147. * @param scene defines the hosting scene
  46148. */
  46149. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46150. /**
  46151. * Gets camera class name
  46152. * @returns AnaglyphGamepadCamera
  46153. */
  46154. getClassName(): string;
  46155. }
  46156. }
  46157. declare module BABYLON {
  46158. /**
  46159. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46160. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46161. */
  46162. export class AnaglyphUniversalCamera extends UniversalCamera {
  46163. /**
  46164. * Creates a new AnaglyphUniversalCamera
  46165. * @param name defines camera name
  46166. * @param position defines initial position
  46167. * @param interaxialDistance defines distance between each color axis
  46168. * @param scene defines the hosting scene
  46169. */
  46170. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46171. /**
  46172. * Gets camera class name
  46173. * @returns AnaglyphUniversalCamera
  46174. */
  46175. getClassName(): string;
  46176. }
  46177. }
  46178. declare module BABYLON {
  46179. /**
  46180. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46181. * @see https://doc.babylonjs.com/features/cameras
  46182. */
  46183. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46184. /**
  46185. * Creates a new StereoscopicArcRotateCamera
  46186. * @param name defines camera name
  46187. * @param alpha defines alpha angle (in radians)
  46188. * @param beta defines beta angle (in radians)
  46189. * @param radius defines radius
  46190. * @param target defines camera target
  46191. * @param interaxialDistance defines distance between each color axis
  46192. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46193. * @param scene defines the hosting scene
  46194. */
  46195. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46196. /**
  46197. * Gets camera class name
  46198. * @returns StereoscopicArcRotateCamera
  46199. */
  46200. getClassName(): string;
  46201. }
  46202. }
  46203. declare module BABYLON {
  46204. /**
  46205. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46206. * @see https://doc.babylonjs.com/features/cameras
  46207. */
  46208. export class StereoscopicFreeCamera extends FreeCamera {
  46209. /**
  46210. * Creates a new StereoscopicFreeCamera
  46211. * @param name defines camera name
  46212. * @param position defines initial position
  46213. * @param interaxialDistance defines distance between each color axis
  46214. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46215. * @param scene defines the hosting scene
  46216. */
  46217. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46218. /**
  46219. * Gets camera class name
  46220. * @returns StereoscopicFreeCamera
  46221. */
  46222. getClassName(): string;
  46223. }
  46224. }
  46225. declare module BABYLON {
  46226. /**
  46227. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46228. * @see https://doc.babylonjs.com/features/cameras
  46229. */
  46230. export class StereoscopicGamepadCamera extends GamepadCamera {
  46231. /**
  46232. * Creates a new StereoscopicGamepadCamera
  46233. * @param name defines camera name
  46234. * @param position defines initial position
  46235. * @param interaxialDistance defines distance between each color axis
  46236. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46237. * @param scene defines the hosting scene
  46238. */
  46239. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46240. /**
  46241. * Gets camera class name
  46242. * @returns StereoscopicGamepadCamera
  46243. */
  46244. getClassName(): string;
  46245. }
  46246. }
  46247. declare module BABYLON {
  46248. /**
  46249. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46250. * @see https://doc.babylonjs.com/features/cameras
  46251. */
  46252. export class StereoscopicUniversalCamera extends UniversalCamera {
  46253. /**
  46254. * Creates a new StereoscopicUniversalCamera
  46255. * @param name defines camera name
  46256. * @param position defines initial position
  46257. * @param interaxialDistance defines distance between each color axis
  46258. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46259. * @param scene defines the hosting scene
  46260. */
  46261. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46262. /**
  46263. * Gets camera class name
  46264. * @returns StereoscopicUniversalCamera
  46265. */
  46266. getClassName(): string;
  46267. }
  46268. }
  46269. declare module BABYLON {
  46270. /**
  46271. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46272. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46273. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46274. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46275. */
  46276. export class VirtualJoysticksCamera extends FreeCamera {
  46277. /**
  46278. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46279. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46280. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46281. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46282. * @param name Define the name of the camera in the scene
  46283. * @param position Define the start position of the camera in the scene
  46284. * @param scene Define the scene the camera belongs to
  46285. */
  46286. constructor(name: string, position: Vector3, scene: Scene);
  46287. /**
  46288. * Gets the current object class name.
  46289. * @return the class name
  46290. */
  46291. getClassName(): string;
  46292. }
  46293. }
  46294. declare module BABYLON {
  46295. /**
  46296. * This represents all the required metrics to create a VR camera.
  46297. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46298. */
  46299. export class VRCameraMetrics {
  46300. /**
  46301. * Define the horizontal resolution off the screen.
  46302. */
  46303. hResolution: number;
  46304. /**
  46305. * Define the vertical resolution off the screen.
  46306. */
  46307. vResolution: number;
  46308. /**
  46309. * Define the horizontal screen size.
  46310. */
  46311. hScreenSize: number;
  46312. /**
  46313. * Define the vertical screen size.
  46314. */
  46315. vScreenSize: number;
  46316. /**
  46317. * Define the vertical screen center position.
  46318. */
  46319. vScreenCenter: number;
  46320. /**
  46321. * Define the distance of the eyes to the screen.
  46322. */
  46323. eyeToScreenDistance: number;
  46324. /**
  46325. * Define the distance between both lenses
  46326. */
  46327. lensSeparationDistance: number;
  46328. /**
  46329. * Define the distance between both viewer's eyes.
  46330. */
  46331. interpupillaryDistance: number;
  46332. /**
  46333. * Define the distortion factor of the VR postprocess.
  46334. * Please, touch with care.
  46335. */
  46336. distortionK: number[];
  46337. /**
  46338. * Define the chromatic aberration correction factors for the VR post process.
  46339. */
  46340. chromaAbCorrection: number[];
  46341. /**
  46342. * Define the scale factor of the post process.
  46343. * The smaller the better but the slower.
  46344. */
  46345. postProcessScaleFactor: number;
  46346. /**
  46347. * Define an offset for the lens center.
  46348. */
  46349. lensCenterOffset: number;
  46350. /**
  46351. * Define if the current vr camera should compensate the distortion of the lense or not.
  46352. */
  46353. compensateDistortion: boolean;
  46354. /**
  46355. * Defines if multiview should be enabled when rendering (Default: false)
  46356. */
  46357. multiviewEnabled: boolean;
  46358. /**
  46359. * Gets the rendering aspect ratio based on the provided resolutions.
  46360. */
  46361. get aspectRatio(): number;
  46362. /**
  46363. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46364. */
  46365. get aspectRatioFov(): number;
  46366. /**
  46367. * @hidden
  46368. */
  46369. get leftHMatrix(): Matrix;
  46370. /**
  46371. * @hidden
  46372. */
  46373. get rightHMatrix(): Matrix;
  46374. /**
  46375. * @hidden
  46376. */
  46377. get leftPreViewMatrix(): Matrix;
  46378. /**
  46379. * @hidden
  46380. */
  46381. get rightPreViewMatrix(): Matrix;
  46382. /**
  46383. * Get the default VRMetrics based on the most generic setup.
  46384. * @returns the default vr metrics
  46385. */
  46386. static GetDefault(): VRCameraMetrics;
  46387. }
  46388. }
  46389. declare module BABYLON {
  46390. /** @hidden */
  46391. export var vrDistortionCorrectionPixelShader: {
  46392. name: string;
  46393. shader: string;
  46394. };
  46395. }
  46396. declare module BABYLON {
  46397. /**
  46398. * VRDistortionCorrectionPostProcess used for mobile VR
  46399. */
  46400. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46401. private _isRightEye;
  46402. private _distortionFactors;
  46403. private _postProcessScaleFactor;
  46404. private _lensCenterOffset;
  46405. private _scaleIn;
  46406. private _scaleFactor;
  46407. private _lensCenter;
  46408. /**
  46409. * Gets a string identifying the name of the class
  46410. * @returns "VRDistortionCorrectionPostProcess" string
  46411. */
  46412. getClassName(): string;
  46413. /**
  46414. * Initializes the VRDistortionCorrectionPostProcess
  46415. * @param name The name of the effect.
  46416. * @param camera The camera to apply the render pass to.
  46417. * @param isRightEye If this is for the right eye distortion
  46418. * @param vrMetrics All the required metrics for the VR camera
  46419. */
  46420. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46421. }
  46422. }
  46423. declare module BABYLON {
  46424. /**
  46425. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46426. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46427. */
  46428. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46429. /**
  46430. * Creates a new VRDeviceOrientationArcRotateCamera
  46431. * @param name defines camera name
  46432. * @param alpha defines the camera rotation along the logitudinal axis
  46433. * @param beta defines the camera rotation along the latitudinal axis
  46434. * @param radius defines the camera distance from its target
  46435. * @param target defines the camera target
  46436. * @param scene defines the scene the camera belongs to
  46437. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46438. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46439. */
  46440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46441. /**
  46442. * Gets camera class name
  46443. * @returns VRDeviceOrientationArcRotateCamera
  46444. */
  46445. getClassName(): string;
  46446. }
  46447. }
  46448. declare module BABYLON {
  46449. /**
  46450. * Camera used to simulate VR rendering (based on FreeCamera)
  46451. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46452. */
  46453. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46454. /**
  46455. * Creates a new VRDeviceOrientationFreeCamera
  46456. * @param name defines camera name
  46457. * @param position defines the start position of the camera
  46458. * @param scene defines the scene the camera belongs to
  46459. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46460. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46461. */
  46462. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46463. /**
  46464. * Gets camera class name
  46465. * @returns VRDeviceOrientationFreeCamera
  46466. */
  46467. getClassName(): string;
  46468. }
  46469. }
  46470. declare module BABYLON {
  46471. /**
  46472. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46473. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46474. */
  46475. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46476. /**
  46477. * Creates a new VRDeviceOrientationGamepadCamera
  46478. * @param name defines camera name
  46479. * @param position defines the start position of the camera
  46480. * @param scene defines the scene the camera belongs to
  46481. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46482. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46483. */
  46484. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46485. /**
  46486. * Gets camera class name
  46487. * @returns VRDeviceOrientationGamepadCamera
  46488. */
  46489. getClassName(): string;
  46490. }
  46491. }
  46492. declare module BABYLON {
  46493. /**
  46494. * A class extending Texture allowing drawing on a texture
  46495. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46496. */
  46497. export class DynamicTexture extends Texture {
  46498. private _generateMipMaps;
  46499. private _canvas;
  46500. private _context;
  46501. /**
  46502. * Creates a DynamicTexture
  46503. * @param name defines the name of the texture
  46504. * @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
  46505. * @param scene defines the scene where you want the texture
  46506. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46507. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46508. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46509. */
  46510. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46511. /**
  46512. * Get the current class name of the texture useful for serialization or dynamic coding.
  46513. * @returns "DynamicTexture"
  46514. */
  46515. getClassName(): string;
  46516. /**
  46517. * Gets the current state of canRescale
  46518. */
  46519. get canRescale(): boolean;
  46520. private _recreate;
  46521. /**
  46522. * Scales the texture
  46523. * @param ratio the scale factor to apply to both width and height
  46524. */
  46525. scale(ratio: number): void;
  46526. /**
  46527. * Resizes the texture
  46528. * @param width the new width
  46529. * @param height the new height
  46530. */
  46531. scaleTo(width: number, height: number): void;
  46532. /**
  46533. * Gets the context of the canvas used by the texture
  46534. * @returns the canvas context of the dynamic texture
  46535. */
  46536. getContext(): CanvasRenderingContext2D;
  46537. /**
  46538. * Clears the texture
  46539. */
  46540. clear(): void;
  46541. /**
  46542. * Updates the texture
  46543. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46544. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46545. */
  46546. update(invertY?: boolean, premulAlpha?: boolean): void;
  46547. /**
  46548. * Draws text onto the texture
  46549. * @param text defines the text to be drawn
  46550. * @param x defines the placement of the text from the left
  46551. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46552. * @param font defines the font to be used with font-style, font-size, font-name
  46553. * @param color defines the color used for the text
  46554. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46555. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46556. * @param update defines whether texture is immediately update (default is true)
  46557. */
  46558. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46559. /**
  46560. * Clones the texture
  46561. * @returns the clone of the texture.
  46562. */
  46563. clone(): DynamicTexture;
  46564. /**
  46565. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46566. * @returns a serialized dynamic texture object
  46567. */
  46568. serialize(): any;
  46569. private _IsCanvasElement;
  46570. /** @hidden */
  46571. _rebuild(): void;
  46572. }
  46573. }
  46574. declare module BABYLON {
  46575. /**
  46576. * Class containing static functions to help procedurally build meshes
  46577. */
  46578. export class GroundBuilder {
  46579. /**
  46580. * Creates a ground mesh
  46581. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46582. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46584. * @param name defines the name of the mesh
  46585. * @param options defines the options used to create the mesh
  46586. * @param scene defines the hosting scene
  46587. * @returns the ground mesh
  46588. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46589. */
  46590. static CreateGround(name: string, options: {
  46591. width?: number;
  46592. height?: number;
  46593. subdivisions?: number;
  46594. subdivisionsX?: number;
  46595. subdivisionsY?: number;
  46596. updatable?: boolean;
  46597. }, scene: any): Mesh;
  46598. /**
  46599. * Creates a tiled ground mesh
  46600. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46601. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46602. * * 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
  46603. * * 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
  46604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46605. * @param name defines the name of the mesh
  46606. * @param options defines the options used to create the mesh
  46607. * @param scene defines the hosting scene
  46608. * @returns the tiled ground mesh
  46609. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46610. */
  46611. static CreateTiledGround(name: string, options: {
  46612. xmin: number;
  46613. zmin: number;
  46614. xmax: number;
  46615. zmax: number;
  46616. subdivisions?: {
  46617. w: number;
  46618. h: number;
  46619. };
  46620. precision?: {
  46621. w: number;
  46622. h: number;
  46623. };
  46624. updatable?: boolean;
  46625. }, scene?: Nullable<Scene>): Mesh;
  46626. /**
  46627. * Creates a ground mesh from a height map
  46628. * * The parameter `url` sets the URL of the height map image resource.
  46629. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46630. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46631. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46632. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46633. * * 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.
  46634. * * 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).
  46635. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46637. * @param name defines the name of the mesh
  46638. * @param url defines the url to the height map
  46639. * @param options defines the options used to create the mesh
  46640. * @param scene defines the hosting scene
  46641. * @returns the ground mesh
  46642. * @see https://doc.babylonjs.com/babylon101/height_map
  46643. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46644. */
  46645. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46646. width?: number;
  46647. height?: number;
  46648. subdivisions?: number;
  46649. minHeight?: number;
  46650. maxHeight?: number;
  46651. colorFilter?: Color3;
  46652. alphaFilter?: number;
  46653. updatable?: boolean;
  46654. onReady?: (mesh: GroundMesh) => void;
  46655. }, scene?: Nullable<Scene>): GroundMesh;
  46656. }
  46657. }
  46658. declare module BABYLON {
  46659. /**
  46660. * Class containing static functions to help procedurally build meshes
  46661. */
  46662. export class TorusBuilder {
  46663. /**
  46664. * Creates a torus mesh
  46665. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46666. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46667. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46669. * * 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
  46670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46671. * @param name defines the name of the mesh
  46672. * @param options defines the options used to create the mesh
  46673. * @param scene defines the hosting scene
  46674. * @returns the torus mesh
  46675. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46676. */
  46677. static CreateTorus(name: string, options: {
  46678. diameter?: number;
  46679. thickness?: number;
  46680. tessellation?: number;
  46681. updatable?: boolean;
  46682. sideOrientation?: number;
  46683. frontUVs?: Vector4;
  46684. backUVs?: Vector4;
  46685. }, scene: any): Mesh;
  46686. }
  46687. }
  46688. declare module BABYLON {
  46689. /**
  46690. * Class containing static functions to help procedurally build meshes
  46691. */
  46692. export class CylinderBuilder {
  46693. /**
  46694. * Creates a cylinder or a cone mesh
  46695. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46696. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46697. * * 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.
  46698. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46699. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46700. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46701. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46702. * * 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).
  46703. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46704. * * 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).
  46705. * * 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
  46706. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46707. * * 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
  46708. * * 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.
  46709. * * If `enclose` is false, a ring surface is one element.
  46710. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46711. * * 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
  46712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46713. * * 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
  46714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46715. * @param name defines the name of the mesh
  46716. * @param options defines the options used to create the mesh
  46717. * @param scene defines the hosting scene
  46718. * @returns the cylinder mesh
  46719. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46720. */
  46721. static CreateCylinder(name: string, options: {
  46722. height?: number;
  46723. diameterTop?: number;
  46724. diameterBottom?: number;
  46725. diameter?: number;
  46726. tessellation?: number;
  46727. subdivisions?: number;
  46728. arc?: number;
  46729. faceColors?: Color4[];
  46730. faceUV?: Vector4[];
  46731. updatable?: boolean;
  46732. hasRings?: boolean;
  46733. enclose?: boolean;
  46734. cap?: number;
  46735. sideOrientation?: number;
  46736. frontUVs?: Vector4;
  46737. backUVs?: Vector4;
  46738. }, scene: any): Mesh;
  46739. }
  46740. }
  46741. declare module BABYLON {
  46742. /**
  46743. * States of the webXR experience
  46744. */
  46745. export enum WebXRState {
  46746. /**
  46747. * Transitioning to being in XR mode
  46748. */
  46749. ENTERING_XR = 0,
  46750. /**
  46751. * Transitioning to non XR mode
  46752. */
  46753. EXITING_XR = 1,
  46754. /**
  46755. * In XR mode and presenting
  46756. */
  46757. IN_XR = 2,
  46758. /**
  46759. * Not entered XR mode
  46760. */
  46761. NOT_IN_XR = 3
  46762. }
  46763. /**
  46764. * Abstraction of the XR render target
  46765. */
  46766. export interface WebXRRenderTarget extends IDisposable {
  46767. /**
  46768. * xrpresent context of the canvas which can be used to display/mirror xr content
  46769. */
  46770. canvasContext: WebGLRenderingContext;
  46771. /**
  46772. * xr layer for the canvas
  46773. */
  46774. xrLayer: Nullable<XRWebGLLayer>;
  46775. /**
  46776. * Initializes the xr layer for the session
  46777. * @param xrSession xr session
  46778. * @returns a promise that will resolve once the XR Layer has been created
  46779. */
  46780. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46781. }
  46782. }
  46783. declare module BABYLON {
  46784. /**
  46785. * COnfiguration object for WebXR output canvas
  46786. */
  46787. export class WebXRManagedOutputCanvasOptions {
  46788. /**
  46789. * An optional canvas in case you wish to create it yourself and provide it here.
  46790. * If not provided, a new canvas will be created
  46791. */
  46792. canvasElement?: HTMLCanvasElement;
  46793. /**
  46794. * Options for this XR Layer output
  46795. */
  46796. canvasOptions?: XRWebGLLayerOptions;
  46797. /**
  46798. * CSS styling for a newly created canvas (if not provided)
  46799. */
  46800. newCanvasCssStyle?: string;
  46801. /**
  46802. * Get the default values of the configuration object
  46803. * @param engine defines the engine to use (can be null)
  46804. * @returns default values of this configuration object
  46805. */
  46806. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46807. }
  46808. /**
  46809. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46810. */
  46811. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46812. private _options;
  46813. private _canvas;
  46814. private _engine;
  46815. private _originalCanvasSize;
  46816. /**
  46817. * Rendering context of the canvas which can be used to display/mirror xr content
  46818. */
  46819. canvasContext: WebGLRenderingContext;
  46820. /**
  46821. * xr layer for the canvas
  46822. */
  46823. xrLayer: Nullable<XRWebGLLayer>;
  46824. /**
  46825. * Obseervers registered here will be triggered when the xr layer was initialized
  46826. */
  46827. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46828. /**
  46829. * Initializes the canvas to be added/removed upon entering/exiting xr
  46830. * @param _xrSessionManager The XR Session manager
  46831. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46832. */
  46833. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46834. /**
  46835. * Disposes of the object
  46836. */
  46837. dispose(): void;
  46838. /**
  46839. * Initializes the xr layer for the session
  46840. * @param xrSession xr session
  46841. * @returns a promise that will resolve once the XR Layer has been created
  46842. */
  46843. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46844. private _addCanvas;
  46845. private _removeCanvas;
  46846. private _setCanvasSize;
  46847. private _setManagedOutputCanvas;
  46848. }
  46849. }
  46850. declare module BABYLON {
  46851. /**
  46852. * Manages an XRSession to work with Babylon's engine
  46853. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46854. */
  46855. export class WebXRSessionManager implements IDisposable {
  46856. /** The scene which the session should be created for */
  46857. scene: Scene;
  46858. private _referenceSpace;
  46859. private _rttProvider;
  46860. private _sessionEnded;
  46861. private _xrNavigator;
  46862. private baseLayer;
  46863. /**
  46864. * The base reference space from which the session started. good if you want to reset your
  46865. * reference space
  46866. */
  46867. baseReferenceSpace: XRReferenceSpace;
  46868. /**
  46869. * Current XR frame
  46870. */
  46871. currentFrame: Nullable<XRFrame>;
  46872. /** WebXR timestamp updated every frame */
  46873. currentTimestamp: number;
  46874. /**
  46875. * Used just in case of a failure to initialize an immersive session.
  46876. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46877. */
  46878. defaultHeightCompensation: number;
  46879. /**
  46880. * Fires every time a new xrFrame arrives which can be used to update the camera
  46881. */
  46882. onXRFrameObservable: Observable<XRFrame>;
  46883. /**
  46884. * Fires when the reference space changed
  46885. */
  46886. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46887. /**
  46888. * Fires when the xr session is ended either by the device or manually done
  46889. */
  46890. onXRSessionEnded: Observable<any>;
  46891. /**
  46892. * Fires when the xr session is ended either by the device or manually done
  46893. */
  46894. onXRSessionInit: Observable<XRSession>;
  46895. /**
  46896. * Underlying xr session
  46897. */
  46898. session: XRSession;
  46899. /**
  46900. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46901. * or get the offset the player is currently at.
  46902. */
  46903. viewerReferenceSpace: XRReferenceSpace;
  46904. /**
  46905. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46906. * @param scene The scene which the session should be created for
  46907. */
  46908. constructor(
  46909. /** The scene which the session should be created for */
  46910. scene: Scene);
  46911. /**
  46912. * The current reference space used in this session. This reference space can constantly change!
  46913. * It is mainly used to offset the camera's position.
  46914. */
  46915. get referenceSpace(): XRReferenceSpace;
  46916. /**
  46917. * Set a new reference space and triggers the observable
  46918. */
  46919. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46920. /**
  46921. * Disposes of the session manager
  46922. */
  46923. dispose(): void;
  46924. /**
  46925. * Stops the xrSession and restores the render loop
  46926. * @returns Promise which resolves after it exits XR
  46927. */
  46928. exitXRAsync(): Promise<void>;
  46929. /**
  46930. * Gets the correct render target texture to be rendered this frame for this eye
  46931. * @param eye the eye for which to get the render target
  46932. * @returns the render target for the specified eye
  46933. */
  46934. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46935. /**
  46936. * Creates a WebXRRenderTarget object for the XR session
  46937. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46938. * @param options optional options to provide when creating a new render target
  46939. * @returns a WebXR render target to which the session can render
  46940. */
  46941. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46942. /**
  46943. * Initializes the manager
  46944. * After initialization enterXR can be called to start an XR session
  46945. * @returns Promise which resolves after it is initialized
  46946. */
  46947. initializeAsync(): Promise<void>;
  46948. /**
  46949. * Initializes an xr session
  46950. * @param xrSessionMode mode to initialize
  46951. * @param xrSessionInit defines optional and required values to pass to the session builder
  46952. * @returns a promise which will resolve once the session has been initialized
  46953. */
  46954. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46955. /**
  46956. * Checks if a session would be supported for the creation options specified
  46957. * @param sessionMode session mode to check if supported eg. immersive-vr
  46958. * @returns A Promise that resolves to true if supported and false if not
  46959. */
  46960. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46961. /**
  46962. * Resets the reference space to the one started the session
  46963. */
  46964. resetReferenceSpace(): void;
  46965. /**
  46966. * Starts rendering to the xr layer
  46967. */
  46968. runXRRenderLoop(): void;
  46969. /**
  46970. * Sets the reference space on the xr session
  46971. * @param referenceSpaceType space to set
  46972. * @returns a promise that will resolve once the reference space has been set
  46973. */
  46974. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46975. /**
  46976. * Updates the render state of the session
  46977. * @param state state to set
  46978. * @returns a promise that resolves once the render state has been updated
  46979. */
  46980. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46981. /**
  46982. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46983. * @param sessionMode defines the session to test
  46984. * @returns a promise with boolean as final value
  46985. */
  46986. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46987. private _createRenderTargetTexture;
  46988. }
  46989. }
  46990. declare module BABYLON {
  46991. /**
  46992. * WebXR Camera which holds the views for the xrSession
  46993. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46994. */
  46995. export class WebXRCamera extends FreeCamera {
  46996. private _xrSessionManager;
  46997. private _firstFrame;
  46998. private _referenceQuaternion;
  46999. private _referencedPosition;
  47000. private _xrInvPositionCache;
  47001. private _xrInvQuaternionCache;
  47002. /**
  47003. * Observable raised before camera teleportation
  47004. */
  47005. onBeforeCameraTeleport: Observable<Vector3>;
  47006. /**
  47007. * Observable raised after camera teleportation
  47008. */
  47009. onAfterCameraTeleport: Observable<Vector3>;
  47010. /**
  47011. * Should position compensation execute on first frame.
  47012. * This is used when copying the position from a native (non XR) camera
  47013. */
  47014. compensateOnFirstFrame: boolean;
  47015. /**
  47016. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47017. * @param name the name of the camera
  47018. * @param scene the scene to add the camera to
  47019. * @param _xrSessionManager a constructed xr session manager
  47020. */
  47021. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47022. /**
  47023. * Return the user's height, unrelated to the current ground.
  47024. * This will be the y position of this camera, when ground level is 0.
  47025. */
  47026. get realWorldHeight(): number;
  47027. /** @hidden */
  47028. _updateForDualEyeDebugging(): void;
  47029. /**
  47030. * Sets this camera's transformation based on a non-vr camera
  47031. * @param otherCamera the non-vr camera to copy the transformation from
  47032. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47033. */
  47034. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47035. /**
  47036. * Gets the current instance class name ("WebXRCamera").
  47037. * @returns the class name
  47038. */
  47039. getClassName(): string;
  47040. private _rotate180;
  47041. private _updateFromXRSession;
  47042. private _updateNumberOfRigCameras;
  47043. private _updateReferenceSpace;
  47044. private _updateReferenceSpaceOffset;
  47045. }
  47046. }
  47047. declare module BABYLON {
  47048. /**
  47049. * Defining the interface required for a (webxr) feature
  47050. */
  47051. export interface IWebXRFeature extends IDisposable {
  47052. /**
  47053. * Is this feature attached
  47054. */
  47055. attached: boolean;
  47056. /**
  47057. * Should auto-attach be disabled?
  47058. */
  47059. disableAutoAttach: boolean;
  47060. /**
  47061. * Attach the feature to the session
  47062. * Will usually be called by the features manager
  47063. *
  47064. * @param force should attachment be forced (even when already attached)
  47065. * @returns true if successful.
  47066. */
  47067. attach(force?: boolean): boolean;
  47068. /**
  47069. * Detach the feature from the session
  47070. * Will usually be called by the features manager
  47071. *
  47072. * @returns true if successful.
  47073. */
  47074. detach(): boolean;
  47075. /**
  47076. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47077. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47078. *
  47079. * @returns whether or not the feature is compatible in this environment
  47080. */
  47081. isCompatible(): boolean;
  47082. /**
  47083. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47084. */
  47085. xrNativeFeatureName?: string;
  47086. /**
  47087. * A list of (Babylon WebXR) features this feature depends on
  47088. */
  47089. dependsOn?: string[];
  47090. }
  47091. /**
  47092. * A list of the currently available features without referencing them
  47093. */
  47094. export class WebXRFeatureName {
  47095. /**
  47096. * The name of the anchor system feature
  47097. */
  47098. static readonly ANCHOR_SYSTEM: string;
  47099. /**
  47100. * The name of the background remover feature
  47101. */
  47102. static readonly BACKGROUND_REMOVER: string;
  47103. /**
  47104. * The name of the hit test feature
  47105. */
  47106. static readonly HIT_TEST: string;
  47107. /**
  47108. * physics impostors for xr controllers feature
  47109. */
  47110. static readonly PHYSICS_CONTROLLERS: string;
  47111. /**
  47112. * The name of the plane detection feature
  47113. */
  47114. static readonly PLANE_DETECTION: string;
  47115. /**
  47116. * The name of the pointer selection feature
  47117. */
  47118. static readonly POINTER_SELECTION: string;
  47119. /**
  47120. * The name of the teleportation feature
  47121. */
  47122. static readonly TELEPORTATION: string;
  47123. /**
  47124. * The name of the feature points feature.
  47125. */
  47126. static readonly FEATURE_POINTS: string;
  47127. /**
  47128. * The name of the hand tracking feature.
  47129. */
  47130. static readonly HAND_TRACKING: string;
  47131. }
  47132. /**
  47133. * Defining the constructor of a feature. Used to register the modules.
  47134. */
  47135. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47136. /**
  47137. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47138. * It is mainly used in AR sessions.
  47139. *
  47140. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47141. */
  47142. export class WebXRFeaturesManager implements IDisposable {
  47143. private _xrSessionManager;
  47144. private static readonly _AvailableFeatures;
  47145. private _features;
  47146. /**
  47147. * constructs a new features manages.
  47148. *
  47149. * @param _xrSessionManager an instance of WebXRSessionManager
  47150. */
  47151. constructor(_xrSessionManager: WebXRSessionManager);
  47152. /**
  47153. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47154. * Mainly used internally.
  47155. *
  47156. * @param featureName the name of the feature to register
  47157. * @param constructorFunction the function used to construct the module
  47158. * @param version the (babylon) version of the module
  47159. * @param stable is that a stable version of this module
  47160. */
  47161. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47162. /**
  47163. * Returns a constructor of a specific feature.
  47164. *
  47165. * @param featureName the name of the feature to construct
  47166. * @param version the version of the feature to load
  47167. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47168. * @param options optional options provided to the module.
  47169. * @returns a function that, when called, will return a new instance of this feature
  47170. */
  47171. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47172. /**
  47173. * Can be used to return the list of features currently registered
  47174. *
  47175. * @returns an Array of available features
  47176. */
  47177. static GetAvailableFeatures(): string[];
  47178. /**
  47179. * Gets the versions available for a specific feature
  47180. * @param featureName the name of the feature
  47181. * @returns an array with the available versions
  47182. */
  47183. static GetAvailableVersions(featureName: string): string[];
  47184. /**
  47185. * Return the latest unstable version of this feature
  47186. * @param featureName the name of the feature to search
  47187. * @returns the version number. if not found will return -1
  47188. */
  47189. static GetLatestVersionOfFeature(featureName: string): number;
  47190. /**
  47191. * Return the latest stable version of this feature
  47192. * @param featureName the name of the feature to search
  47193. * @returns the version number. if not found will return -1
  47194. */
  47195. static GetStableVersionOfFeature(featureName: string): number;
  47196. /**
  47197. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47198. * Can be used during a session to start a feature
  47199. * @param featureName the name of feature to attach
  47200. */
  47201. attachFeature(featureName: string): void;
  47202. /**
  47203. * Can be used inside a session or when the session ends to detach a specific feature
  47204. * @param featureName the name of the feature to detach
  47205. */
  47206. detachFeature(featureName: string): void;
  47207. /**
  47208. * Used to disable an already-enabled feature
  47209. * The feature will be disposed and will be recreated once enabled.
  47210. * @param featureName the feature to disable
  47211. * @returns true if disable was successful
  47212. */
  47213. disableFeature(featureName: string | {
  47214. Name: string;
  47215. }): boolean;
  47216. /**
  47217. * dispose this features manager
  47218. */
  47219. dispose(): void;
  47220. /**
  47221. * 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.
  47222. * 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.
  47223. *
  47224. * @param featureName the name of the feature to load or the class of the feature
  47225. * @param version optional version to load. if not provided the latest version will be enabled
  47226. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47227. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47228. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47229. * @returns a new constructed feature or throws an error if feature not found.
  47230. */
  47231. enableFeature(featureName: string | {
  47232. Name: string;
  47233. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47234. /**
  47235. * get the implementation of an enabled feature.
  47236. * @param featureName the name of the feature to load
  47237. * @returns the feature class, if found
  47238. */
  47239. getEnabledFeature(featureName: string): IWebXRFeature;
  47240. /**
  47241. * Get the list of enabled features
  47242. * @returns an array of enabled features
  47243. */
  47244. getEnabledFeatures(): string[];
  47245. /**
  47246. * This function will exten the session creation configuration object with enabled features.
  47247. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47248. * according to the defined "required" variable, provided during enableFeature call
  47249. * @param xrSessionInit the xr Session init object to extend
  47250. *
  47251. * @returns an extended XRSessionInit object
  47252. */
  47253. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47254. }
  47255. }
  47256. declare module BABYLON {
  47257. /**
  47258. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47259. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47260. */
  47261. export class WebXRExperienceHelper implements IDisposable {
  47262. private scene;
  47263. private _nonVRCamera;
  47264. private _originalSceneAutoClear;
  47265. private _supported;
  47266. /**
  47267. * Camera used to render xr content
  47268. */
  47269. camera: WebXRCamera;
  47270. /** A features manager for this xr session */
  47271. featuresManager: WebXRFeaturesManager;
  47272. /**
  47273. * Observers registered here will be triggered after the camera's initial transformation is set
  47274. * This can be used to set a different ground level or an extra rotation.
  47275. *
  47276. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47277. * to the position set after this observable is done executing.
  47278. */
  47279. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47280. /**
  47281. * Fires when the state of the experience helper has changed
  47282. */
  47283. onStateChangedObservable: Observable<WebXRState>;
  47284. /** Session manager used to keep track of xr session */
  47285. sessionManager: WebXRSessionManager;
  47286. /**
  47287. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47288. */
  47289. state: WebXRState;
  47290. /**
  47291. * Creates a WebXRExperienceHelper
  47292. * @param scene The scene the helper should be created in
  47293. */
  47294. private constructor();
  47295. /**
  47296. * Creates the experience helper
  47297. * @param scene the scene to attach the experience helper to
  47298. * @returns a promise for the experience helper
  47299. */
  47300. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47301. /**
  47302. * Disposes of the experience helper
  47303. */
  47304. dispose(): void;
  47305. /**
  47306. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47307. * @param sessionMode options for the XR session
  47308. * @param referenceSpaceType frame of reference of the XR session
  47309. * @param renderTarget the output canvas that will be used to enter XR mode
  47310. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47311. * @returns promise that resolves after xr mode has entered
  47312. */
  47313. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47314. /**
  47315. * Exits XR mode and returns the scene to its original state
  47316. * @returns promise that resolves after xr mode has exited
  47317. */
  47318. exitXRAsync(): Promise<void>;
  47319. private _nonXRToXRCamera;
  47320. private _setState;
  47321. }
  47322. }
  47323. declare module BABYLON {
  47324. /**
  47325. * X-Y values for axes in WebXR
  47326. */
  47327. export interface IWebXRMotionControllerAxesValue {
  47328. /**
  47329. * The value of the x axis
  47330. */
  47331. x: number;
  47332. /**
  47333. * The value of the y-axis
  47334. */
  47335. y: number;
  47336. }
  47337. /**
  47338. * changed / previous values for the values of this component
  47339. */
  47340. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47341. /**
  47342. * current (this frame) value
  47343. */
  47344. current: T;
  47345. /**
  47346. * previous (last change) value
  47347. */
  47348. previous: T;
  47349. }
  47350. /**
  47351. * Represents changes in the component between current frame and last values recorded
  47352. */
  47353. export interface IWebXRMotionControllerComponentChanges {
  47354. /**
  47355. * will be populated with previous and current values if axes changed
  47356. */
  47357. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47358. /**
  47359. * will be populated with previous and current values if pressed changed
  47360. */
  47361. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47362. /**
  47363. * will be populated with previous and current values if touched changed
  47364. */
  47365. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47366. /**
  47367. * will be populated with previous and current values if value changed
  47368. */
  47369. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47370. }
  47371. /**
  47372. * This class represents a single component (for example button or thumbstick) of a motion controller
  47373. */
  47374. export class WebXRControllerComponent implements IDisposable {
  47375. /**
  47376. * the id of this component
  47377. */
  47378. id: string;
  47379. /**
  47380. * the type of the component
  47381. */
  47382. type: MotionControllerComponentType;
  47383. private _buttonIndex;
  47384. private _axesIndices;
  47385. private _axes;
  47386. private _changes;
  47387. private _currentValue;
  47388. private _hasChanges;
  47389. private _pressed;
  47390. private _touched;
  47391. /**
  47392. * button component type
  47393. */
  47394. static BUTTON_TYPE: MotionControllerComponentType;
  47395. /**
  47396. * squeeze component type
  47397. */
  47398. static SQUEEZE_TYPE: MotionControllerComponentType;
  47399. /**
  47400. * Thumbstick component type
  47401. */
  47402. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47403. /**
  47404. * Touchpad component type
  47405. */
  47406. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47407. /**
  47408. * trigger component type
  47409. */
  47410. static TRIGGER_TYPE: MotionControllerComponentType;
  47411. /**
  47412. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47413. * the axes data changes
  47414. */
  47415. onAxisValueChangedObservable: Observable<{
  47416. x: number;
  47417. y: number;
  47418. }>;
  47419. /**
  47420. * Observers registered here will be triggered when the state of a button changes
  47421. * State change is either pressed / touched / value
  47422. */
  47423. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47424. /**
  47425. * Creates a new component for a motion controller.
  47426. * It is created by the motion controller itself
  47427. *
  47428. * @param id the id of this component
  47429. * @param type the type of the component
  47430. * @param _buttonIndex index in the buttons array of the gamepad
  47431. * @param _axesIndices indices of the values in the axes array of the gamepad
  47432. */
  47433. constructor(
  47434. /**
  47435. * the id of this component
  47436. */
  47437. id: string,
  47438. /**
  47439. * the type of the component
  47440. */
  47441. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47442. /**
  47443. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47444. */
  47445. get axes(): IWebXRMotionControllerAxesValue;
  47446. /**
  47447. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47448. */
  47449. get changes(): IWebXRMotionControllerComponentChanges;
  47450. /**
  47451. * Return whether or not the component changed the last frame
  47452. */
  47453. get hasChanges(): boolean;
  47454. /**
  47455. * is the button currently pressed
  47456. */
  47457. get pressed(): boolean;
  47458. /**
  47459. * is the button currently touched
  47460. */
  47461. get touched(): boolean;
  47462. /**
  47463. * Get the current value of this component
  47464. */
  47465. get value(): number;
  47466. /**
  47467. * Dispose this component
  47468. */
  47469. dispose(): void;
  47470. /**
  47471. * Are there axes correlating to this component
  47472. * @return true is axes data is available
  47473. */
  47474. isAxes(): boolean;
  47475. /**
  47476. * Is this component a button (hence - pressable)
  47477. * @returns true if can be pressed
  47478. */
  47479. isButton(): boolean;
  47480. /**
  47481. * update this component using the gamepad object it is in. Called on every frame
  47482. * @param nativeController the native gamepad controller object
  47483. */
  47484. update(nativeController: IMinimalMotionControllerObject): void;
  47485. }
  47486. }
  47487. declare module BABYLON {
  47488. /**
  47489. * Interface used to represent data loading progression
  47490. */
  47491. export interface ISceneLoaderProgressEvent {
  47492. /**
  47493. * Defines if data length to load can be evaluated
  47494. */
  47495. readonly lengthComputable: boolean;
  47496. /**
  47497. * Defines the loaded data length
  47498. */
  47499. readonly loaded: number;
  47500. /**
  47501. * Defines the data length to load
  47502. */
  47503. readonly total: number;
  47504. }
  47505. /**
  47506. * Interface used by SceneLoader plugins to define supported file extensions
  47507. */
  47508. export interface ISceneLoaderPluginExtensions {
  47509. /**
  47510. * Defines the list of supported extensions
  47511. */
  47512. [extension: string]: {
  47513. isBinary: boolean;
  47514. };
  47515. }
  47516. /**
  47517. * Interface used by SceneLoader plugin factory
  47518. */
  47519. export interface ISceneLoaderPluginFactory {
  47520. /**
  47521. * Defines the name of the factory
  47522. */
  47523. name: string;
  47524. /**
  47525. * Function called to create a new plugin
  47526. * @return the new plugin
  47527. */
  47528. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47529. /**
  47530. * The callback that returns true if the data can be directly loaded.
  47531. * @param data string containing the file data
  47532. * @returns if the data can be loaded directly
  47533. */
  47534. canDirectLoad?(data: string): boolean;
  47535. }
  47536. /**
  47537. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47538. */
  47539. export interface ISceneLoaderPluginBase {
  47540. /**
  47541. * The friendly name of this plugin.
  47542. */
  47543. name: string;
  47544. /**
  47545. * The file extensions supported by this plugin.
  47546. */
  47547. extensions: string | ISceneLoaderPluginExtensions;
  47548. /**
  47549. * The callback called when loading from a url.
  47550. * @param scene scene loading this url
  47551. * @param url url to load
  47552. * @param onSuccess callback called when the file successfully loads
  47553. * @param onProgress callback called while file is loading (if the server supports this mode)
  47554. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47555. * @param onError callback called when the file fails to load
  47556. * @returns a file request object
  47557. */
  47558. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47559. /**
  47560. * The callback called when loading from a file object.
  47561. * @param scene scene loading this file
  47562. * @param file defines the file to load
  47563. * @param onSuccess defines the callback to call when data is loaded
  47564. * @param onProgress defines the callback to call during loading process
  47565. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47566. * @param onError defines the callback to call when an error occurs
  47567. * @returns a file request object
  47568. */
  47569. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47570. /**
  47571. * The callback that returns true if the data can be directly loaded.
  47572. * @param data string containing the file data
  47573. * @returns if the data can be loaded directly
  47574. */
  47575. canDirectLoad?(data: string): boolean;
  47576. /**
  47577. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47578. * @param scene scene loading this data
  47579. * @param data string containing the data
  47580. * @returns data to pass to the plugin
  47581. */
  47582. directLoad?(scene: Scene, data: string): any;
  47583. /**
  47584. * The callback that allows custom handling of the root url based on the response url.
  47585. * @param rootUrl the original root url
  47586. * @param responseURL the response url if available
  47587. * @returns the new root url
  47588. */
  47589. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47590. }
  47591. /**
  47592. * Interface used to define a SceneLoader plugin
  47593. */
  47594. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47595. /**
  47596. * Import meshes into a scene.
  47597. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47598. * @param scene The scene to import into
  47599. * @param data The data to import
  47600. * @param rootUrl The root url for scene and resources
  47601. * @param meshes The meshes array to import into
  47602. * @param particleSystems The particle systems array to import into
  47603. * @param skeletons The skeletons array to import into
  47604. * @param onError The callback when import fails
  47605. * @returns True if successful or false otherwise
  47606. */
  47607. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47608. /**
  47609. * Load into a scene.
  47610. * @param scene The scene to load into
  47611. * @param data The data to import
  47612. * @param rootUrl The root url for scene and resources
  47613. * @param onError The callback when import fails
  47614. * @returns True if successful or false otherwise
  47615. */
  47616. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47617. /**
  47618. * Load into an asset container.
  47619. * @param scene The scene to load into
  47620. * @param data The data to import
  47621. * @param rootUrl The root url for scene and resources
  47622. * @param onError The callback when import fails
  47623. * @returns The loaded asset container
  47624. */
  47625. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47626. }
  47627. /**
  47628. * Interface used to define an async SceneLoader plugin
  47629. */
  47630. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47631. /**
  47632. * Import meshes into a scene.
  47633. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47634. * @param scene The scene to import into
  47635. * @param data The data to import
  47636. * @param rootUrl The root url for scene and resources
  47637. * @param onProgress The callback when the load progresses
  47638. * @param fileName Defines the name of the file to load
  47639. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47640. */
  47641. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47642. meshes: AbstractMesh[];
  47643. particleSystems: IParticleSystem[];
  47644. skeletons: Skeleton[];
  47645. animationGroups: AnimationGroup[];
  47646. }>;
  47647. /**
  47648. * Load into a scene.
  47649. * @param scene The scene to load into
  47650. * @param data The data to import
  47651. * @param rootUrl The root url for scene and resources
  47652. * @param onProgress The callback when the load progresses
  47653. * @param fileName Defines the name of the file to load
  47654. * @returns Nothing
  47655. */
  47656. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47657. /**
  47658. * Load into an asset container.
  47659. * @param scene The scene to load into
  47660. * @param data The data to import
  47661. * @param rootUrl The root url for scene and resources
  47662. * @param onProgress The callback when the load progresses
  47663. * @param fileName Defines the name of the file to load
  47664. * @returns The loaded asset container
  47665. */
  47666. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47667. }
  47668. /**
  47669. * Mode that determines how to handle old animation groups before loading new ones.
  47670. */
  47671. export enum SceneLoaderAnimationGroupLoadingMode {
  47672. /**
  47673. * Reset all old animations to initial state then dispose them.
  47674. */
  47675. Clean = 0,
  47676. /**
  47677. * Stop all old animations.
  47678. */
  47679. Stop = 1,
  47680. /**
  47681. * Restart old animations from first frame.
  47682. */
  47683. Sync = 2,
  47684. /**
  47685. * Old animations remains untouched.
  47686. */
  47687. NoSync = 3
  47688. }
  47689. /**
  47690. * Defines a plugin registered by the SceneLoader
  47691. */
  47692. interface IRegisteredPlugin {
  47693. /**
  47694. * Defines the plugin to use
  47695. */
  47696. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47697. /**
  47698. * Defines if the plugin supports binary data
  47699. */
  47700. isBinary: boolean;
  47701. }
  47702. /**
  47703. * Class used to load scene from various file formats using registered plugins
  47704. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47705. */
  47706. export class SceneLoader {
  47707. /**
  47708. * No logging while loading
  47709. */
  47710. static readonly NO_LOGGING: number;
  47711. /**
  47712. * Minimal logging while loading
  47713. */
  47714. static readonly MINIMAL_LOGGING: number;
  47715. /**
  47716. * Summary logging while loading
  47717. */
  47718. static readonly SUMMARY_LOGGING: number;
  47719. /**
  47720. * Detailled logging while loading
  47721. */
  47722. static readonly DETAILED_LOGGING: number;
  47723. /**
  47724. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47725. */
  47726. static get ForceFullSceneLoadingForIncremental(): boolean;
  47727. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47728. /**
  47729. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47730. */
  47731. static get ShowLoadingScreen(): boolean;
  47732. static set ShowLoadingScreen(value: boolean);
  47733. /**
  47734. * Defines the current logging level (while loading the scene)
  47735. * @ignorenaming
  47736. */
  47737. static get loggingLevel(): number;
  47738. static set loggingLevel(value: number);
  47739. /**
  47740. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47741. */
  47742. static get CleanBoneMatrixWeights(): boolean;
  47743. static set CleanBoneMatrixWeights(value: boolean);
  47744. /**
  47745. * Event raised when a plugin is used to load a scene
  47746. */
  47747. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47748. private static _registeredPlugins;
  47749. private static _showingLoadingScreen;
  47750. /**
  47751. * Gets the default plugin (used to load Babylon files)
  47752. * @returns the .babylon plugin
  47753. */
  47754. static GetDefaultPlugin(): IRegisteredPlugin;
  47755. private static _GetPluginForExtension;
  47756. private static _GetPluginForDirectLoad;
  47757. private static _GetPluginForFilename;
  47758. private static _GetDirectLoad;
  47759. private static _LoadData;
  47760. private static _GetFileInfo;
  47761. /**
  47762. * Gets a plugin that can load the given extension
  47763. * @param extension defines the extension to load
  47764. * @returns a plugin or null if none works
  47765. */
  47766. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47767. /**
  47768. * Gets a boolean indicating that the given extension can be loaded
  47769. * @param extension defines the extension to load
  47770. * @returns true if the extension is supported
  47771. */
  47772. static IsPluginForExtensionAvailable(extension: string): boolean;
  47773. /**
  47774. * Adds a new plugin to the list of registered plugins
  47775. * @param plugin defines the plugin to add
  47776. */
  47777. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47778. /**
  47779. * Import meshes into a scene
  47780. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47781. * @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)
  47782. * @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)
  47783. * @param scene the instance of BABYLON.Scene to append to
  47784. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47785. * @param onProgress a callback with a progress event for each file being loaded
  47786. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47787. * @param pluginExtension the extension used to determine the plugin
  47788. * @returns The loaded plugin
  47789. */
  47790. 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>;
  47791. /**
  47792. * Import meshes into a scene
  47793. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47794. * @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)
  47795. * @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)
  47796. * @param scene the instance of BABYLON.Scene to append to
  47797. * @param onProgress a callback with a progress event for each file being loaded
  47798. * @param pluginExtension the extension used to determine the plugin
  47799. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47800. */
  47801. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47802. meshes: AbstractMesh[];
  47803. particleSystems: IParticleSystem[];
  47804. skeletons: Skeleton[];
  47805. animationGroups: AnimationGroup[];
  47806. }>;
  47807. /**
  47808. * Load a scene
  47809. * @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)
  47810. * @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)
  47811. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47812. * @param onSuccess a callback with the scene when import succeeds
  47813. * @param onProgress a callback with a progress event for each file being loaded
  47814. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47815. * @param pluginExtension the extension used to determine the plugin
  47816. * @returns The loaded plugin
  47817. */
  47818. 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>;
  47819. /**
  47820. * Load a scene
  47821. * @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)
  47822. * @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)
  47823. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47824. * @param onProgress a callback with a progress event for each file being loaded
  47825. * @param pluginExtension the extension used to determine the plugin
  47826. * @returns The loaded scene
  47827. */
  47828. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47829. /**
  47830. * Append a scene
  47831. * @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)
  47832. * @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)
  47833. * @param scene is the instance of BABYLON.Scene to append to
  47834. * @param onSuccess a callback with the scene when import succeeds
  47835. * @param onProgress a callback with a progress event for each file being loaded
  47836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47837. * @param pluginExtension the extension used to determine the plugin
  47838. * @returns The loaded plugin
  47839. */
  47840. 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>;
  47841. /**
  47842. * Append a scene
  47843. * @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)
  47844. * @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)
  47845. * @param scene is the instance of BABYLON.Scene to append to
  47846. * @param onProgress a callback with a progress event for each file being loaded
  47847. * @param pluginExtension the extension used to determine the plugin
  47848. * @returns The given scene
  47849. */
  47850. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47851. /**
  47852. * Load a scene into an asset container
  47853. * @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)
  47854. * @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)
  47855. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47856. * @param onSuccess a callback with the scene when import succeeds
  47857. * @param onProgress a callback with a progress event for each file being loaded
  47858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47859. * @param pluginExtension the extension used to determine the plugin
  47860. * @returns The loaded plugin
  47861. */
  47862. 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>;
  47863. /**
  47864. * Load a scene into an asset container
  47865. * @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)
  47866. * @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)
  47867. * @param scene is the instance of Scene to append to
  47868. * @param onProgress a callback with a progress event for each file being loaded
  47869. * @param pluginExtension the extension used to determine the plugin
  47870. * @returns The loaded asset container
  47871. */
  47872. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47873. /**
  47874. * Import animations from a file into a scene
  47875. * @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)
  47876. * @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)
  47877. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47878. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47879. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47880. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47881. * @param onSuccess a callback with the scene when import succeeds
  47882. * @param onProgress a callback with a progress event for each file being loaded
  47883. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47884. * @param pluginExtension the extension used to determine the plugin
  47885. */
  47886. 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;
  47887. /**
  47888. * Import animations from a file into a scene
  47889. * @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)
  47890. * @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)
  47891. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47892. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47893. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47894. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47895. * @param onSuccess a callback with the scene when import succeeds
  47896. * @param onProgress a callback with a progress event for each file being loaded
  47897. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47898. * @param pluginExtension the extension used to determine the plugin
  47899. * @returns the updated scene with imported animations
  47900. */
  47901. 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>;
  47902. }
  47903. }
  47904. declare module BABYLON {
  47905. /**
  47906. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47907. */
  47908. export type MotionControllerHandedness = "none" | "left" | "right";
  47909. /**
  47910. * The type of components available in motion controllers.
  47911. * This is not the name of the component.
  47912. */
  47913. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47914. /**
  47915. * The state of a controller component
  47916. */
  47917. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47918. /**
  47919. * The schema of motion controller layout.
  47920. * No object will be initialized using this interface
  47921. * This is used just to define the profile.
  47922. */
  47923. export interface IMotionControllerLayout {
  47924. /**
  47925. * Path to load the assets. Usually relative to the base path
  47926. */
  47927. assetPath: string;
  47928. /**
  47929. * Available components (unsorted)
  47930. */
  47931. components: {
  47932. /**
  47933. * A map of component Ids
  47934. */
  47935. [componentId: string]: {
  47936. /**
  47937. * The type of input the component outputs
  47938. */
  47939. type: MotionControllerComponentType;
  47940. /**
  47941. * The indices of this component in the gamepad object
  47942. */
  47943. gamepadIndices: {
  47944. /**
  47945. * Index of button
  47946. */
  47947. button?: number;
  47948. /**
  47949. * If available, index of x-axis
  47950. */
  47951. xAxis?: number;
  47952. /**
  47953. * If available, index of y-axis
  47954. */
  47955. yAxis?: number;
  47956. };
  47957. /**
  47958. * The mesh's root node name
  47959. */
  47960. rootNodeName: string;
  47961. /**
  47962. * Animation definitions for this model
  47963. */
  47964. visualResponses: {
  47965. [stateKey: string]: {
  47966. /**
  47967. * What property will be animated
  47968. */
  47969. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47970. /**
  47971. * What states influence this visual response
  47972. */
  47973. states: MotionControllerComponentStateType[];
  47974. /**
  47975. * Type of animation - movement or visibility
  47976. */
  47977. valueNodeProperty: "transform" | "visibility";
  47978. /**
  47979. * Base node name to move. Its position will be calculated according to the min and max nodes
  47980. */
  47981. valueNodeName?: string;
  47982. /**
  47983. * Minimum movement node
  47984. */
  47985. minNodeName?: string;
  47986. /**
  47987. * Max movement node
  47988. */
  47989. maxNodeName?: string;
  47990. };
  47991. };
  47992. /**
  47993. * If touch enabled, what is the name of node to display user feedback
  47994. */
  47995. touchPointNodeName?: string;
  47996. };
  47997. };
  47998. /**
  47999. * Is it xr standard mapping or not
  48000. */
  48001. gamepadMapping: "" | "xr-standard";
  48002. /**
  48003. * Base root node of this entire model
  48004. */
  48005. rootNodeName: string;
  48006. /**
  48007. * Defines the main button component id
  48008. */
  48009. selectComponentId: string;
  48010. }
  48011. /**
  48012. * A definition for the layout map in the input profile
  48013. */
  48014. export interface IMotionControllerLayoutMap {
  48015. /**
  48016. * Layouts with handedness type as a key
  48017. */
  48018. [handedness: string]: IMotionControllerLayout;
  48019. }
  48020. /**
  48021. * The XR Input profile schema
  48022. * Profiles can be found here:
  48023. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48024. */
  48025. export interface IMotionControllerProfile {
  48026. /**
  48027. * fallback profiles for this profileId
  48028. */
  48029. fallbackProfileIds: string[];
  48030. /**
  48031. * The layout map, with handedness as key
  48032. */
  48033. layouts: IMotionControllerLayoutMap;
  48034. /**
  48035. * The id of this profile
  48036. * correlates to the profile(s) in the xrInput.profiles array
  48037. */
  48038. profileId: string;
  48039. }
  48040. /**
  48041. * A helper-interface for the 3 meshes needed for controller button animation
  48042. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48043. */
  48044. export interface IMotionControllerButtonMeshMap {
  48045. /**
  48046. * the mesh that defines the pressed value mesh position.
  48047. * This is used to find the max-position of this button
  48048. */
  48049. pressedMesh: AbstractMesh;
  48050. /**
  48051. * the mesh that defines the unpressed value mesh position.
  48052. * This is used to find the min (or initial) position of this button
  48053. */
  48054. unpressedMesh: AbstractMesh;
  48055. /**
  48056. * The mesh that will be changed when value changes
  48057. */
  48058. valueMesh: AbstractMesh;
  48059. }
  48060. /**
  48061. * A helper-interface for the 3 meshes needed for controller axis animation.
  48062. * This will be expanded when touchpad animations are fully supported
  48063. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48064. */
  48065. export interface IMotionControllerMeshMap {
  48066. /**
  48067. * the mesh that defines the maximum value mesh position.
  48068. */
  48069. maxMesh?: AbstractMesh;
  48070. /**
  48071. * the mesh that defines the minimum value mesh position.
  48072. */
  48073. minMesh?: AbstractMesh;
  48074. /**
  48075. * The mesh that will be changed when axis value changes
  48076. */
  48077. valueMesh?: AbstractMesh;
  48078. }
  48079. /**
  48080. * The elements needed for change-detection of the gamepad objects in motion controllers
  48081. */
  48082. export interface IMinimalMotionControllerObject {
  48083. /**
  48084. * Available axes of this controller
  48085. */
  48086. axes: number[];
  48087. /**
  48088. * An array of available buttons
  48089. */
  48090. buttons: Array<{
  48091. /**
  48092. * Value of the button/trigger
  48093. */
  48094. value: number;
  48095. /**
  48096. * If the button/trigger is currently touched
  48097. */
  48098. touched: boolean;
  48099. /**
  48100. * If the button/trigger is currently pressed
  48101. */
  48102. pressed: boolean;
  48103. }>;
  48104. /**
  48105. * EXPERIMENTAL haptic support.
  48106. */
  48107. hapticActuators?: Array<{
  48108. pulse: (value: number, duration: number) => Promise<boolean>;
  48109. }>;
  48110. }
  48111. /**
  48112. * An Abstract Motion controller
  48113. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48114. * Each component has an observable to check for changes in value and state
  48115. */
  48116. export abstract class WebXRAbstractMotionController implements IDisposable {
  48117. protected scene: Scene;
  48118. protected layout: IMotionControllerLayout;
  48119. /**
  48120. * The gamepad object correlating to this controller
  48121. */
  48122. gamepadObject: IMinimalMotionControllerObject;
  48123. /**
  48124. * handedness (left/right/none) of this controller
  48125. */
  48126. handedness: MotionControllerHandedness;
  48127. private _initComponent;
  48128. private _modelReady;
  48129. /**
  48130. * A map of components (WebXRControllerComponent) in this motion controller
  48131. * Components have a ComponentType and can also have both button and axis definitions
  48132. */
  48133. readonly components: {
  48134. [id: string]: WebXRControllerComponent;
  48135. };
  48136. /**
  48137. * Disable the model's animation. Can be set at any time.
  48138. */
  48139. disableAnimation: boolean;
  48140. /**
  48141. * Observers registered here will be triggered when the model of this controller is done loading
  48142. */
  48143. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48144. /**
  48145. * The profile id of this motion controller
  48146. */
  48147. abstract profileId: string;
  48148. /**
  48149. * The root mesh of the model. It is null if the model was not yet initialized
  48150. */
  48151. rootMesh: Nullable<AbstractMesh>;
  48152. /**
  48153. * constructs a new abstract motion controller
  48154. * @param scene the scene to which the model of the controller will be added
  48155. * @param layout The profile layout to load
  48156. * @param gamepadObject The gamepad object correlating to this controller
  48157. * @param handedness handedness (left/right/none) of this controller
  48158. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48159. */
  48160. constructor(scene: Scene, layout: IMotionControllerLayout,
  48161. /**
  48162. * The gamepad object correlating to this controller
  48163. */
  48164. gamepadObject: IMinimalMotionControllerObject,
  48165. /**
  48166. * handedness (left/right/none) of this controller
  48167. */
  48168. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48169. /**
  48170. * Dispose this controller, the model mesh and all its components
  48171. */
  48172. dispose(): void;
  48173. /**
  48174. * Returns all components of specific type
  48175. * @param type the type to search for
  48176. * @return an array of components with this type
  48177. */
  48178. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48179. /**
  48180. * get a component based an its component id as defined in layout.components
  48181. * @param id the id of the component
  48182. * @returns the component correlates to the id or undefined if not found
  48183. */
  48184. getComponent(id: string): WebXRControllerComponent;
  48185. /**
  48186. * Get the list of components available in this motion controller
  48187. * @returns an array of strings correlating to available components
  48188. */
  48189. getComponentIds(): string[];
  48190. /**
  48191. * Get the first component of specific type
  48192. * @param type type of component to find
  48193. * @return a controller component or null if not found
  48194. */
  48195. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48196. /**
  48197. * Get the main (Select) component of this controller as defined in the layout
  48198. * @returns the main component of this controller
  48199. */
  48200. getMainComponent(): WebXRControllerComponent;
  48201. /**
  48202. * Loads the model correlating to this controller
  48203. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48204. * @returns A promise fulfilled with the result of the model loading
  48205. */
  48206. loadModel(): Promise<boolean>;
  48207. /**
  48208. * Update this model using the current XRFrame
  48209. * @param xrFrame the current xr frame to use and update the model
  48210. */
  48211. updateFromXRFrame(xrFrame: XRFrame): void;
  48212. /**
  48213. * Backwards compatibility due to a deeply-integrated typo
  48214. */
  48215. get handness(): XREye;
  48216. /**
  48217. * Pulse (vibrate) this controller
  48218. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48219. * Consecutive calls to this function will cancel the last pulse call
  48220. *
  48221. * @param value the strength of the pulse in 0.0...1.0 range
  48222. * @param duration Duration of the pulse in milliseconds
  48223. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48224. * @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
  48225. */
  48226. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48227. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48228. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48229. /**
  48230. * Moves the axis on the controller mesh based on its current state
  48231. * @param axis the index of the axis
  48232. * @param axisValue the value of the axis which determines the meshes new position
  48233. * @hidden
  48234. */
  48235. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48236. /**
  48237. * Update the model itself with the current frame data
  48238. * @param xrFrame the frame to use for updating the model mesh
  48239. */
  48240. protected updateModel(xrFrame: XRFrame): void;
  48241. /**
  48242. * Get the filename and path for this controller's model
  48243. * @returns a map of filename and path
  48244. */
  48245. protected abstract _getFilenameAndPath(): {
  48246. filename: string;
  48247. path: string;
  48248. };
  48249. /**
  48250. * This function is called before the mesh is loaded. It checks for loading constraints.
  48251. * For example, this function can check if the GLB loader is available
  48252. * If this function returns false, the generic controller will be loaded instead
  48253. * @returns Is the client ready to load the mesh
  48254. */
  48255. protected abstract _getModelLoadingConstraints(): boolean;
  48256. /**
  48257. * This function will be called after the model was successfully loaded and can be used
  48258. * for mesh transformations before it is available for the user
  48259. * @param meshes the loaded meshes
  48260. */
  48261. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48262. /**
  48263. * Set the root mesh for this controller. Important for the WebXR controller class
  48264. * @param meshes the loaded meshes
  48265. */
  48266. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48267. /**
  48268. * A function executed each frame that updates the mesh (if needed)
  48269. * @param xrFrame the current xrFrame
  48270. */
  48271. protected abstract _updateModel(xrFrame: XRFrame): void;
  48272. private _getGenericFilenameAndPath;
  48273. private _getGenericParentMesh;
  48274. }
  48275. }
  48276. declare module BABYLON {
  48277. /**
  48278. * A generic trigger-only motion controller for WebXR
  48279. */
  48280. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48281. /**
  48282. * Static version of the profile id of this controller
  48283. */
  48284. static ProfileId: string;
  48285. profileId: string;
  48286. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48287. protected _getFilenameAndPath(): {
  48288. filename: string;
  48289. path: string;
  48290. };
  48291. protected _getModelLoadingConstraints(): boolean;
  48292. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48293. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48294. protected _updateModel(): void;
  48295. }
  48296. }
  48297. declare module BABYLON {
  48298. /**
  48299. * Class containing static functions to help procedurally build meshes
  48300. */
  48301. export class SphereBuilder {
  48302. /**
  48303. * Creates a sphere mesh
  48304. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48305. * * 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`)
  48306. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48307. * * 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
  48308. * * 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)
  48309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48310. * * 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
  48311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48312. * @param name defines the name of the mesh
  48313. * @param options defines the options used to create the mesh
  48314. * @param scene defines the hosting scene
  48315. * @returns the sphere mesh
  48316. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48317. */
  48318. static CreateSphere(name: string, options: {
  48319. segments?: number;
  48320. diameter?: number;
  48321. diameterX?: number;
  48322. diameterY?: number;
  48323. diameterZ?: number;
  48324. arc?: number;
  48325. slice?: number;
  48326. sideOrientation?: number;
  48327. frontUVs?: Vector4;
  48328. backUVs?: Vector4;
  48329. updatable?: boolean;
  48330. }, scene?: Nullable<Scene>): Mesh;
  48331. }
  48332. }
  48333. declare module BABYLON {
  48334. /**
  48335. * A profiled motion controller has its profile loaded from an online repository.
  48336. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48337. */
  48338. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48339. private _repositoryUrl;
  48340. private _buttonMeshMapping;
  48341. private _touchDots;
  48342. /**
  48343. * The profile ID of this controller. Will be populated when the controller initializes.
  48344. */
  48345. profileId: string;
  48346. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48347. dispose(): void;
  48348. protected _getFilenameAndPath(): {
  48349. filename: string;
  48350. path: string;
  48351. };
  48352. protected _getModelLoadingConstraints(): boolean;
  48353. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48354. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48355. protected _updateModel(_xrFrame: XRFrame): void;
  48356. }
  48357. }
  48358. declare module BABYLON {
  48359. /**
  48360. * A construction function type to create a new controller based on an xrInput object
  48361. */
  48362. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48363. /**
  48364. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48365. *
  48366. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48367. * it should be replaced with auto-loaded controllers.
  48368. *
  48369. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48370. */
  48371. export class WebXRMotionControllerManager {
  48372. private static _AvailableControllers;
  48373. private static _Fallbacks;
  48374. private static _ProfileLoadingPromises;
  48375. private static _ProfilesList;
  48376. /**
  48377. * The base URL of the online controller repository. Can be changed at any time.
  48378. */
  48379. static BaseRepositoryUrl: string;
  48380. /**
  48381. * Which repository gets priority - local or online
  48382. */
  48383. static PrioritizeOnlineRepository: boolean;
  48384. /**
  48385. * Use the online repository, or use only locally-defined controllers
  48386. */
  48387. static UseOnlineRepository: boolean;
  48388. /**
  48389. * Clear the cache used for profile loading and reload when requested again
  48390. */
  48391. static ClearProfilesCache(): void;
  48392. /**
  48393. * Register the default fallbacks.
  48394. * This function is called automatically when this file is imported.
  48395. */
  48396. static DefaultFallbacks(): void;
  48397. /**
  48398. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48399. * @param profileId the profile to which a fallback needs to be found
  48400. * @return an array with corresponding fallback profiles
  48401. */
  48402. static FindFallbackWithProfileId(profileId: string): string[];
  48403. /**
  48404. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48405. * The order of search:
  48406. *
  48407. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48408. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48409. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48410. * 4) return the generic trigger controller if none were found
  48411. *
  48412. * @param xrInput the xrInput to which a new controller is initialized
  48413. * @param scene the scene to which the model will be added
  48414. * @param forceProfile force a certain profile for this controller
  48415. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48416. */
  48417. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48418. /**
  48419. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48420. *
  48421. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48422. *
  48423. * @param type the profile type to register
  48424. * @param constructFunction the function to be called when loading this profile
  48425. */
  48426. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48427. /**
  48428. * Register a fallback to a specific profile.
  48429. * @param profileId the profileId that will receive the fallbacks
  48430. * @param fallbacks A list of fallback profiles
  48431. */
  48432. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48433. /**
  48434. * Will update the list of profiles available in the repository
  48435. * @return a promise that resolves to a map of profiles available online
  48436. */
  48437. static UpdateProfilesList(): Promise<{
  48438. [profile: string]: string;
  48439. }>;
  48440. private static _LoadProfileFromRepository;
  48441. private static _LoadProfilesFromAvailableControllers;
  48442. }
  48443. }
  48444. declare module BABYLON {
  48445. /**
  48446. * Configuration options for the WebXR controller creation
  48447. */
  48448. export interface IWebXRControllerOptions {
  48449. /**
  48450. * Should the controller mesh be animated when a user interacts with it
  48451. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48452. */
  48453. disableMotionControllerAnimation?: boolean;
  48454. /**
  48455. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48456. */
  48457. doNotLoadControllerMesh?: boolean;
  48458. /**
  48459. * Force a specific controller type for this controller.
  48460. * This can be used when creating your own profile or when testing different controllers
  48461. */
  48462. forceControllerProfile?: string;
  48463. /**
  48464. * Defines a rendering group ID for meshes that will be loaded.
  48465. * This is for the default controllers only.
  48466. */
  48467. renderingGroupId?: number;
  48468. }
  48469. /**
  48470. * Represents an XR controller
  48471. */
  48472. export class WebXRInputSource {
  48473. private _scene;
  48474. /** The underlying input source for the controller */
  48475. inputSource: XRInputSource;
  48476. private _options;
  48477. private _tmpVector;
  48478. private _uniqueId;
  48479. private _disposed;
  48480. /**
  48481. * 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
  48482. */
  48483. grip?: AbstractMesh;
  48484. /**
  48485. * If available, this is the gamepad object related to this controller.
  48486. * Using this object it is possible to get click events and trackpad changes of the
  48487. * webxr controller that is currently being used.
  48488. */
  48489. motionController?: WebXRAbstractMotionController;
  48490. /**
  48491. * Event that fires when the controller is removed/disposed.
  48492. * The object provided as event data is this controller, after associated assets were disposed.
  48493. * uniqueId is still available.
  48494. */
  48495. onDisposeObservable: Observable<WebXRInputSource>;
  48496. /**
  48497. * Will be triggered when the mesh associated with the motion controller is done loading.
  48498. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48499. * A shortened version of controller -> motion controller -> on mesh loaded.
  48500. */
  48501. onMeshLoadedObservable: Observable<AbstractMesh>;
  48502. /**
  48503. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48504. */
  48505. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48506. /**
  48507. * Pointer which can be used to select objects or attach a visible laser to
  48508. */
  48509. pointer: AbstractMesh;
  48510. /**
  48511. * Creates the input source object
  48512. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48513. * @param _scene the scene which the controller should be associated to
  48514. * @param inputSource the underlying input source for the controller
  48515. * @param _options options for this controller creation
  48516. */
  48517. constructor(_scene: Scene,
  48518. /** The underlying input source for the controller */
  48519. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48520. /**
  48521. * Get this controllers unique id
  48522. */
  48523. get uniqueId(): string;
  48524. /**
  48525. * Disposes of the object
  48526. */
  48527. dispose(): void;
  48528. /**
  48529. * Gets a world space ray coming from the pointer or grip
  48530. * @param result the resulting ray
  48531. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48532. */
  48533. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48534. /**
  48535. * Updates the controller pose based on the given XRFrame
  48536. * @param xrFrame xr frame to update the pose with
  48537. * @param referenceSpace reference space to use
  48538. */
  48539. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48540. }
  48541. }
  48542. declare module BABYLON {
  48543. /**
  48544. * The schema for initialization options of the XR Input class
  48545. */
  48546. export interface IWebXRInputOptions {
  48547. /**
  48548. * If set to true no model will be automatically loaded
  48549. */
  48550. doNotLoadControllerMeshes?: boolean;
  48551. /**
  48552. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48553. * If not found, the xr input profile data will be used.
  48554. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48555. */
  48556. forceInputProfile?: string;
  48557. /**
  48558. * Do not send a request to the controller repository to load the profile.
  48559. *
  48560. * Instead, use the controllers available in babylon itself.
  48561. */
  48562. disableOnlineControllerRepository?: boolean;
  48563. /**
  48564. * A custom URL for the controllers repository
  48565. */
  48566. customControllersRepositoryURL?: string;
  48567. /**
  48568. * Should the controller model's components not move according to the user input
  48569. */
  48570. disableControllerAnimation?: boolean;
  48571. /**
  48572. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48573. */
  48574. controllerOptions?: IWebXRControllerOptions;
  48575. }
  48576. /**
  48577. * XR input used to track XR inputs such as controllers/rays
  48578. */
  48579. export class WebXRInput implements IDisposable {
  48580. /**
  48581. * the xr session manager for this session
  48582. */
  48583. xrSessionManager: WebXRSessionManager;
  48584. /**
  48585. * the WebXR camera for this session. Mainly used for teleportation
  48586. */
  48587. xrCamera: WebXRCamera;
  48588. private readonly options;
  48589. /**
  48590. * XR controllers being tracked
  48591. */
  48592. controllers: Array<WebXRInputSource>;
  48593. private _frameObserver;
  48594. private _sessionEndedObserver;
  48595. private _sessionInitObserver;
  48596. /**
  48597. * Event when a controller has been connected/added
  48598. */
  48599. onControllerAddedObservable: Observable<WebXRInputSource>;
  48600. /**
  48601. * Event when a controller has been removed/disconnected
  48602. */
  48603. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48604. /**
  48605. * Initializes the WebXRInput
  48606. * @param xrSessionManager the xr session manager for this session
  48607. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48608. * @param options = initialization options for this xr input
  48609. */
  48610. constructor(
  48611. /**
  48612. * the xr session manager for this session
  48613. */
  48614. xrSessionManager: WebXRSessionManager,
  48615. /**
  48616. * the WebXR camera for this session. Mainly used for teleportation
  48617. */
  48618. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48619. private _onInputSourcesChange;
  48620. private _addAndRemoveControllers;
  48621. /**
  48622. * Disposes of the object
  48623. */
  48624. dispose(): void;
  48625. }
  48626. }
  48627. declare module BABYLON {
  48628. /**
  48629. * This is the base class for all WebXR features.
  48630. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48631. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48632. */
  48633. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48634. protected _xrSessionManager: WebXRSessionManager;
  48635. private _attached;
  48636. private _removeOnDetach;
  48637. /**
  48638. * Should auto-attach be disabled?
  48639. */
  48640. disableAutoAttach: boolean;
  48641. /**
  48642. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48643. */
  48644. xrNativeFeatureName: string;
  48645. /**
  48646. * Construct a new (abstract) WebXR feature
  48647. * @param _xrSessionManager the xr session manager for this feature
  48648. */
  48649. constructor(_xrSessionManager: WebXRSessionManager);
  48650. /**
  48651. * Is this feature attached
  48652. */
  48653. get attached(): boolean;
  48654. /**
  48655. * attach this feature
  48656. *
  48657. * @param force should attachment be forced (even when already attached)
  48658. * @returns true if successful, false is failed or already attached
  48659. */
  48660. attach(force?: boolean): boolean;
  48661. /**
  48662. * detach this feature.
  48663. *
  48664. * @returns true if successful, false if failed or already detached
  48665. */
  48666. detach(): boolean;
  48667. /**
  48668. * Dispose this feature and all of the resources attached
  48669. */
  48670. dispose(): void;
  48671. /**
  48672. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48673. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48674. *
  48675. * @returns whether or not the feature is compatible in this environment
  48676. */
  48677. isCompatible(): boolean;
  48678. /**
  48679. * This is used to register callbacks that will automatically be removed when detach is called.
  48680. * @param observable the observable to which the observer will be attached
  48681. * @param callback the callback to register
  48682. */
  48683. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48684. /**
  48685. * Code in this function will be executed on each xrFrame received from the browser.
  48686. * This function will not execute after the feature is detached.
  48687. * @param _xrFrame the current frame
  48688. */
  48689. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48690. }
  48691. }
  48692. declare module BABYLON {
  48693. /**
  48694. * Renders a layer on top of an existing scene
  48695. */
  48696. export class UtilityLayerRenderer implements IDisposable {
  48697. /** the original scene that will be rendered on top of */
  48698. originalScene: Scene;
  48699. private _pointerCaptures;
  48700. private _lastPointerEvents;
  48701. private static _DefaultUtilityLayer;
  48702. private static _DefaultKeepDepthUtilityLayer;
  48703. private _sharedGizmoLight;
  48704. private _renderCamera;
  48705. /**
  48706. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48707. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48708. * @returns the camera that is used when rendering the utility layer
  48709. */
  48710. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48711. /**
  48712. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48713. * @param cam the camera that should be used when rendering the utility layer
  48714. */
  48715. setRenderCamera(cam: Nullable<Camera>): void;
  48716. /**
  48717. * @hidden
  48718. * Light which used by gizmos to get light shading
  48719. */
  48720. _getSharedGizmoLight(): HemisphericLight;
  48721. /**
  48722. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48723. */
  48724. pickUtilitySceneFirst: boolean;
  48725. /**
  48726. * 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)
  48727. */
  48728. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48729. /**
  48730. * 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)
  48731. */
  48732. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48733. /**
  48734. * The scene that is rendered on top of the original scene
  48735. */
  48736. utilityLayerScene: Scene;
  48737. /**
  48738. * If the utility layer should automatically be rendered on top of existing scene
  48739. */
  48740. shouldRender: boolean;
  48741. /**
  48742. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48743. */
  48744. onlyCheckPointerDownEvents: boolean;
  48745. /**
  48746. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48747. */
  48748. processAllEvents: boolean;
  48749. /**
  48750. * Observable raised when the pointer move from the utility layer scene to the main scene
  48751. */
  48752. onPointerOutObservable: Observable<number>;
  48753. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48754. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48755. private _afterRenderObserver;
  48756. private _sceneDisposeObserver;
  48757. private _originalPointerObserver;
  48758. /**
  48759. * Instantiates a UtilityLayerRenderer
  48760. * @param originalScene the original scene that will be rendered on top of
  48761. * @param handleEvents boolean indicating if the utility layer should handle events
  48762. */
  48763. constructor(
  48764. /** the original scene that will be rendered on top of */
  48765. originalScene: Scene, handleEvents?: boolean);
  48766. private _notifyObservers;
  48767. /**
  48768. * Renders the utility layers scene on top of the original scene
  48769. */
  48770. render(): void;
  48771. /**
  48772. * Disposes of the renderer
  48773. */
  48774. dispose(): void;
  48775. private _updateCamera;
  48776. }
  48777. }
  48778. declare module BABYLON {
  48779. /**
  48780. * Options interface for the pointer selection module
  48781. */
  48782. export interface IWebXRControllerPointerSelectionOptions {
  48783. /**
  48784. * if provided, this scene will be used to render meshes.
  48785. */
  48786. customUtilityLayerScene?: Scene;
  48787. /**
  48788. * 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)
  48789. * If not disabled, the last picked point will be used to execute a pointer up event
  48790. * If disabled, pointer up event will be triggered right after the pointer down event.
  48791. * Used in screen and gaze target ray mode only
  48792. */
  48793. disablePointerUpOnTouchOut: boolean;
  48794. /**
  48795. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48796. */
  48797. forceGazeMode: boolean;
  48798. /**
  48799. * 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
  48800. * to start a new countdown to the pointer down event.
  48801. * Defaults to 1.
  48802. */
  48803. gazeModePointerMovedFactor?: number;
  48804. /**
  48805. * Different button type to use instead of the main component
  48806. */
  48807. overrideButtonId?: string;
  48808. /**
  48809. * use this rendering group id for the meshes (optional)
  48810. */
  48811. renderingGroupId?: number;
  48812. /**
  48813. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48814. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48815. * 3000 means 3 seconds between pointing at something and selecting it
  48816. */
  48817. timeToSelect?: number;
  48818. /**
  48819. * Should meshes created here be added to a utility layer or the main scene
  48820. */
  48821. useUtilityLayer?: boolean;
  48822. /**
  48823. * Optional WebXR camera to be used for gaze selection
  48824. */
  48825. gazeCamera?: WebXRCamera;
  48826. /**
  48827. * the xr input to use with this pointer selection
  48828. */
  48829. xrInput: WebXRInput;
  48830. }
  48831. /**
  48832. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48833. */
  48834. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48835. private readonly _options;
  48836. private static _idCounter;
  48837. private _attachController;
  48838. private _controllers;
  48839. private _scene;
  48840. private _tmpVectorForPickCompare;
  48841. /**
  48842. * The module's name
  48843. */
  48844. static readonly Name: string;
  48845. /**
  48846. * The (Babylon) version of this module.
  48847. * This is an integer representing the implementation version.
  48848. * This number does not correspond to the WebXR specs version
  48849. */
  48850. static readonly Version: number;
  48851. /**
  48852. * Disable lighting on the laser pointer (so it will always be visible)
  48853. */
  48854. disablePointerLighting: boolean;
  48855. /**
  48856. * Disable lighting on the selection mesh (so it will always be visible)
  48857. */
  48858. disableSelectionMeshLighting: boolean;
  48859. /**
  48860. * Should the laser pointer be displayed
  48861. */
  48862. displayLaserPointer: boolean;
  48863. /**
  48864. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48865. */
  48866. displaySelectionMesh: boolean;
  48867. /**
  48868. * This color will be set to the laser pointer when selection is triggered
  48869. */
  48870. laserPointerPickedColor: Color3;
  48871. /**
  48872. * Default color of the laser pointer
  48873. */
  48874. laserPointerDefaultColor: Color3;
  48875. /**
  48876. * default color of the selection ring
  48877. */
  48878. selectionMeshDefaultColor: Color3;
  48879. /**
  48880. * This color will be applied to the selection ring when selection is triggered
  48881. */
  48882. selectionMeshPickedColor: Color3;
  48883. /**
  48884. * Optional filter to be used for ray selection. This predicate shares behavior with
  48885. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48886. */
  48887. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48888. /**
  48889. * constructs a new background remover module
  48890. * @param _xrSessionManager the session manager for this module
  48891. * @param _options read-only options to be used in this module
  48892. */
  48893. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48894. /**
  48895. * attach this feature
  48896. * Will usually be called by the features manager
  48897. *
  48898. * @returns true if successful.
  48899. */
  48900. attach(): boolean;
  48901. /**
  48902. * detach this feature.
  48903. * Will usually be called by the features manager
  48904. *
  48905. * @returns true if successful.
  48906. */
  48907. detach(): boolean;
  48908. /**
  48909. * Will get the mesh under a specific pointer.
  48910. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48911. * @param controllerId the controllerId to check
  48912. * @returns The mesh under pointer or null if no mesh is under the pointer
  48913. */
  48914. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48915. /**
  48916. * Get the xr controller that correlates to the pointer id in the pointer event
  48917. *
  48918. * @param id the pointer id to search for
  48919. * @returns the controller that correlates to this id or null if not found
  48920. */
  48921. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48922. protected _onXRFrame(_xrFrame: XRFrame): void;
  48923. private _attachGazeMode;
  48924. private _attachScreenRayMode;
  48925. private _attachTrackedPointerRayMode;
  48926. private _convertNormalToDirectionOfRay;
  48927. private _detachController;
  48928. private _generateNewMeshPair;
  48929. private _pickingMoved;
  48930. private _updatePointerDistance;
  48931. /** @hidden */
  48932. get lasterPointerDefaultColor(): Color3;
  48933. }
  48934. }
  48935. declare module BABYLON {
  48936. /**
  48937. * Button which can be used to enter a different mode of XR
  48938. */
  48939. export class WebXREnterExitUIButton {
  48940. /** button element */
  48941. element: HTMLElement;
  48942. /** XR initialization options for the button */
  48943. sessionMode: XRSessionMode;
  48944. /** Reference space type */
  48945. referenceSpaceType: XRReferenceSpaceType;
  48946. /**
  48947. * Creates a WebXREnterExitUIButton
  48948. * @param element button element
  48949. * @param sessionMode XR initialization session mode
  48950. * @param referenceSpaceType the type of reference space to be used
  48951. */
  48952. constructor(
  48953. /** button element */
  48954. element: HTMLElement,
  48955. /** XR initialization options for the button */
  48956. sessionMode: XRSessionMode,
  48957. /** Reference space type */
  48958. referenceSpaceType: XRReferenceSpaceType);
  48959. /**
  48960. * Extendable function which can be used to update the button's visuals when the state changes
  48961. * @param activeButton the current active button in the UI
  48962. */
  48963. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48964. }
  48965. /**
  48966. * Options to create the webXR UI
  48967. */
  48968. export class WebXREnterExitUIOptions {
  48969. /**
  48970. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48971. */
  48972. customButtons?: Array<WebXREnterExitUIButton>;
  48973. /**
  48974. * A reference space type to use when creating the default button.
  48975. * Default is local-floor
  48976. */
  48977. referenceSpaceType?: XRReferenceSpaceType;
  48978. /**
  48979. * Context to enter xr with
  48980. */
  48981. renderTarget?: Nullable<WebXRRenderTarget>;
  48982. /**
  48983. * A session mode to use when creating the default button.
  48984. * Default is immersive-vr
  48985. */
  48986. sessionMode?: XRSessionMode;
  48987. /**
  48988. * A list of optional features to init the session with
  48989. */
  48990. optionalFeatures?: string[];
  48991. /**
  48992. * A list of optional features to init the session with
  48993. */
  48994. requiredFeatures?: string[];
  48995. }
  48996. /**
  48997. * UI to allow the user to enter/exit XR mode
  48998. */
  48999. export class WebXREnterExitUI implements IDisposable {
  49000. private scene;
  49001. /** version of the options passed to this UI */
  49002. options: WebXREnterExitUIOptions;
  49003. private _activeButton;
  49004. private _buttons;
  49005. /**
  49006. * The HTML Div Element to which buttons are added.
  49007. */
  49008. readonly overlay: HTMLDivElement;
  49009. /**
  49010. * Fired every time the active button is changed.
  49011. *
  49012. * When xr is entered via a button that launches xr that button will be the callback parameter
  49013. *
  49014. * When exiting xr the callback parameter will be null)
  49015. */
  49016. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49017. /**
  49018. *
  49019. * @param scene babylon scene object to use
  49020. * @param options (read-only) version of the options passed to this UI
  49021. */
  49022. private constructor();
  49023. /**
  49024. * Creates UI to allow the user to enter/exit XR mode
  49025. * @param scene the scene to add the ui to
  49026. * @param helper the xr experience helper to enter/exit xr with
  49027. * @param options options to configure the UI
  49028. * @returns the created ui
  49029. */
  49030. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49031. /**
  49032. * Disposes of the XR UI component
  49033. */
  49034. dispose(): void;
  49035. private _updateButtons;
  49036. }
  49037. }
  49038. declare module BABYLON {
  49039. /**
  49040. * Class containing static functions to help procedurally build meshes
  49041. */
  49042. export class LinesBuilder {
  49043. /**
  49044. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49045. * * 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
  49046. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49047. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49048. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49049. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49050. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49051. * * 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
  49052. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49055. * @param name defines the name of the new line system
  49056. * @param options defines the options used to create the line system
  49057. * @param scene defines the hosting scene
  49058. * @returns a new line system mesh
  49059. */
  49060. static CreateLineSystem(name: string, options: {
  49061. lines: Vector3[][];
  49062. updatable?: boolean;
  49063. instance?: Nullable<LinesMesh>;
  49064. colors?: Nullable<Color4[][]>;
  49065. useVertexAlpha?: boolean;
  49066. }, scene: Nullable<Scene>): LinesMesh;
  49067. /**
  49068. * Creates a line mesh
  49069. * 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
  49070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49071. * * The parameter `points` is an array successive Vector3
  49072. * * 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
  49073. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49074. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49075. * * When updating an instance, remember that only point positions can change, not the number of points
  49076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49078. * @param name defines the name of the new line system
  49079. * @param options defines the options used to create the line system
  49080. * @param scene defines the hosting scene
  49081. * @returns a new line mesh
  49082. */
  49083. static CreateLines(name: string, options: {
  49084. points: Vector3[];
  49085. updatable?: boolean;
  49086. instance?: Nullable<LinesMesh>;
  49087. colors?: Color4[];
  49088. useVertexAlpha?: boolean;
  49089. }, scene?: Nullable<Scene>): LinesMesh;
  49090. /**
  49091. * Creates a dashed line mesh
  49092. * * 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
  49093. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49094. * * The parameter `points` is an array successive Vector3
  49095. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49096. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49097. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49098. * * 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
  49099. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49100. * * When updating an instance, remember that only point positions can change, not the number of points
  49101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49102. * @param name defines the name of the mesh
  49103. * @param options defines the options used to create the mesh
  49104. * @param scene defines the hosting scene
  49105. * @returns the dashed line mesh
  49106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49107. */
  49108. static CreateDashedLines(name: string, options: {
  49109. points: Vector3[];
  49110. dashSize?: number;
  49111. gapSize?: number;
  49112. dashNb?: number;
  49113. updatable?: boolean;
  49114. instance?: LinesMesh;
  49115. useVertexAlpha?: boolean;
  49116. }, scene?: Nullable<Scene>): LinesMesh;
  49117. }
  49118. }
  49119. declare module BABYLON {
  49120. /**
  49121. * Construction options for a timer
  49122. */
  49123. export interface ITimerOptions<T> {
  49124. /**
  49125. * Time-to-end
  49126. */
  49127. timeout: number;
  49128. /**
  49129. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49130. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49131. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49132. */
  49133. contextObservable: Observable<T>;
  49134. /**
  49135. * Optional parameters when adding an observer to the observable
  49136. */
  49137. observableParameters?: {
  49138. mask?: number;
  49139. insertFirst?: boolean;
  49140. scope?: any;
  49141. };
  49142. /**
  49143. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49144. */
  49145. breakCondition?: (data?: ITimerData<T>) => boolean;
  49146. /**
  49147. * Will be triggered when the time condition has met
  49148. */
  49149. onEnded?: (data: ITimerData<any>) => void;
  49150. /**
  49151. * Will be triggered when the break condition has met (prematurely ended)
  49152. */
  49153. onAborted?: (data: ITimerData<any>) => void;
  49154. /**
  49155. * Optional function to execute on each tick (or count)
  49156. */
  49157. onTick?: (data: ITimerData<any>) => void;
  49158. }
  49159. /**
  49160. * An interface defining the data sent by the timer
  49161. */
  49162. export interface ITimerData<T> {
  49163. /**
  49164. * When did it start
  49165. */
  49166. startTime: number;
  49167. /**
  49168. * Time now
  49169. */
  49170. currentTime: number;
  49171. /**
  49172. * Time passed since started
  49173. */
  49174. deltaTime: number;
  49175. /**
  49176. * How much is completed, in [0.0...1.0].
  49177. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49178. */
  49179. completeRate: number;
  49180. /**
  49181. * What the registered observable sent in the last count
  49182. */
  49183. payload: T;
  49184. }
  49185. /**
  49186. * The current state of the timer
  49187. */
  49188. export enum TimerState {
  49189. /**
  49190. * Timer initialized, not yet started
  49191. */
  49192. INIT = 0,
  49193. /**
  49194. * Timer started and counting
  49195. */
  49196. STARTED = 1,
  49197. /**
  49198. * Timer ended (whether aborted or time reached)
  49199. */
  49200. ENDED = 2
  49201. }
  49202. /**
  49203. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49204. *
  49205. * @param options options with which to initialize this timer
  49206. */
  49207. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49208. /**
  49209. * An advanced implementation of a timer class
  49210. */
  49211. export class AdvancedTimer<T = any> implements IDisposable {
  49212. /**
  49213. * Will notify each time the timer calculates the remaining time
  49214. */
  49215. onEachCountObservable: Observable<ITimerData<T>>;
  49216. /**
  49217. * Will trigger when the timer was aborted due to the break condition
  49218. */
  49219. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49220. /**
  49221. * Will trigger when the timer ended successfully
  49222. */
  49223. onTimerEndedObservable: Observable<ITimerData<T>>;
  49224. /**
  49225. * Will trigger when the timer state has changed
  49226. */
  49227. onStateChangedObservable: Observable<TimerState>;
  49228. private _observer;
  49229. private _contextObservable;
  49230. private _observableParameters;
  49231. private _startTime;
  49232. private _timer;
  49233. private _state;
  49234. private _breakCondition;
  49235. private _timeToEnd;
  49236. private _breakOnNextTick;
  49237. /**
  49238. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49239. * @param options construction options for this advanced timer
  49240. */
  49241. constructor(options: ITimerOptions<T>);
  49242. /**
  49243. * set a breaking condition for this timer. Default is to never break during count
  49244. * @param predicate the new break condition. Returns true to break, false otherwise
  49245. */
  49246. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49247. /**
  49248. * Reset ALL associated observables in this advanced timer
  49249. */
  49250. clearObservables(): void;
  49251. /**
  49252. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49253. *
  49254. * @param timeToEnd how much time to measure until timer ended
  49255. */
  49256. start(timeToEnd?: number): void;
  49257. /**
  49258. * Will force a stop on the next tick.
  49259. */
  49260. stop(): void;
  49261. /**
  49262. * Dispose this timer, clearing all resources
  49263. */
  49264. dispose(): void;
  49265. private _setState;
  49266. private _tick;
  49267. private _stop;
  49268. }
  49269. }
  49270. declare module BABYLON {
  49271. /**
  49272. * The options container for the teleportation module
  49273. */
  49274. export interface IWebXRTeleportationOptions {
  49275. /**
  49276. * if provided, this scene will be used to render meshes.
  49277. */
  49278. customUtilityLayerScene?: Scene;
  49279. /**
  49280. * Values to configure the default target mesh
  49281. */
  49282. defaultTargetMeshOptions?: {
  49283. /**
  49284. * Fill color of the teleportation area
  49285. */
  49286. teleportationFillColor?: string;
  49287. /**
  49288. * Border color for the teleportation area
  49289. */
  49290. teleportationBorderColor?: string;
  49291. /**
  49292. * Disable the mesh's animation sequence
  49293. */
  49294. disableAnimation?: boolean;
  49295. /**
  49296. * Disable lighting on the material or the ring and arrow
  49297. */
  49298. disableLighting?: boolean;
  49299. /**
  49300. * Override the default material of the torus and arrow
  49301. */
  49302. torusArrowMaterial?: Material;
  49303. };
  49304. /**
  49305. * A list of meshes to use as floor meshes.
  49306. * Meshes can be added and removed after initializing the feature using the
  49307. * addFloorMesh and removeFloorMesh functions
  49308. * If empty, rotation will still work
  49309. */
  49310. floorMeshes?: AbstractMesh[];
  49311. /**
  49312. * use this rendering group id for the meshes (optional)
  49313. */
  49314. renderingGroupId?: number;
  49315. /**
  49316. * Should teleportation move only to snap points
  49317. */
  49318. snapPointsOnly?: boolean;
  49319. /**
  49320. * An array of points to which the teleportation will snap to.
  49321. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49322. */
  49323. snapPositions?: Vector3[];
  49324. /**
  49325. * How close should the teleportation ray be in order to snap to position.
  49326. * Default to 0.8 units (meters)
  49327. */
  49328. snapToPositionRadius?: number;
  49329. /**
  49330. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49331. * If you want to support rotation, make sure your mesh has a direction indicator.
  49332. *
  49333. * When left untouched, the default mesh will be initialized.
  49334. */
  49335. teleportationTargetMesh?: AbstractMesh;
  49336. /**
  49337. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49338. */
  49339. timeToTeleport?: number;
  49340. /**
  49341. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49342. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49343. */
  49344. useMainComponentOnly?: boolean;
  49345. /**
  49346. * Should meshes created here be added to a utility layer or the main scene
  49347. */
  49348. useUtilityLayer?: boolean;
  49349. /**
  49350. * Babylon XR Input class for controller
  49351. */
  49352. xrInput: WebXRInput;
  49353. }
  49354. /**
  49355. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49356. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49357. * the input of the attached controllers.
  49358. */
  49359. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49360. private _options;
  49361. private _controllers;
  49362. private _currentTeleportationControllerId;
  49363. private _floorMeshes;
  49364. private _quadraticBezierCurve;
  49365. private _selectionFeature;
  49366. private _snapToPositions;
  49367. private _snappedToPoint;
  49368. private _teleportationRingMaterial?;
  49369. private _tmpRay;
  49370. private _tmpVector;
  49371. /**
  49372. * The module's name
  49373. */
  49374. static readonly Name: string;
  49375. /**
  49376. * The (Babylon) version of this module.
  49377. * This is an integer representing the implementation version.
  49378. * This number does not correspond to the webxr specs version
  49379. */
  49380. static readonly Version: number;
  49381. /**
  49382. * Is movement backwards enabled
  49383. */
  49384. backwardsMovementEnabled: boolean;
  49385. /**
  49386. * Distance to travel when moving backwards
  49387. */
  49388. backwardsTeleportationDistance: number;
  49389. /**
  49390. * The distance from the user to the inspection point in the direction of the controller
  49391. * A higher number will allow the user to move further
  49392. * defaults to 5 (meters, in xr units)
  49393. */
  49394. parabolicCheckRadius: number;
  49395. /**
  49396. * Should the module support parabolic ray on top of direct ray
  49397. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49398. * Very helpful when moving between floors / different heights
  49399. */
  49400. parabolicRayEnabled: boolean;
  49401. /**
  49402. * How much rotation should be applied when rotating right and left
  49403. */
  49404. rotationAngle: number;
  49405. /**
  49406. * Is rotation enabled when moving forward?
  49407. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49408. */
  49409. rotationEnabled: boolean;
  49410. /**
  49411. * constructs a new anchor system
  49412. * @param _xrSessionManager an instance of WebXRSessionManager
  49413. * @param _options configuration object for this feature
  49414. */
  49415. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49416. /**
  49417. * Get the snapPointsOnly flag
  49418. */
  49419. get snapPointsOnly(): boolean;
  49420. /**
  49421. * Sets the snapPointsOnly flag
  49422. * @param snapToPoints should teleportation be exclusively to snap points
  49423. */
  49424. set snapPointsOnly(snapToPoints: boolean);
  49425. /**
  49426. * Add a new mesh to the floor meshes array
  49427. * @param mesh the mesh to use as floor mesh
  49428. */
  49429. addFloorMesh(mesh: AbstractMesh): void;
  49430. /**
  49431. * Add a new snap-to point to fix teleportation to this position
  49432. * @param newSnapPoint The new Snap-To point
  49433. */
  49434. addSnapPoint(newSnapPoint: Vector3): void;
  49435. attach(): boolean;
  49436. detach(): boolean;
  49437. dispose(): void;
  49438. /**
  49439. * Remove a mesh from the floor meshes array
  49440. * @param mesh the mesh to remove
  49441. */
  49442. removeFloorMesh(mesh: AbstractMesh): void;
  49443. /**
  49444. * Remove a mesh from the floor meshes array using its name
  49445. * @param name the mesh name to remove
  49446. */
  49447. removeFloorMeshByName(name: string): void;
  49448. /**
  49449. * 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
  49450. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49451. * @returns was the point found and removed or not
  49452. */
  49453. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49454. /**
  49455. * This function sets a selection feature that will be disabled when
  49456. * the forward ray is shown and will be reattached when hidden.
  49457. * This is used to remove the selection rays when moving.
  49458. * @param selectionFeature the feature to disable when forward movement is enabled
  49459. */
  49460. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49461. protected _onXRFrame(_xrFrame: XRFrame): void;
  49462. private _attachController;
  49463. private _createDefaultTargetMesh;
  49464. private _detachController;
  49465. private _findClosestSnapPointWithRadius;
  49466. private _setTargetMeshPosition;
  49467. private _setTargetMeshVisibility;
  49468. private _showParabolicPath;
  49469. private _teleportForward;
  49470. }
  49471. }
  49472. declare module BABYLON {
  49473. /**
  49474. * Options for the default xr helper
  49475. */
  49476. export class WebXRDefaultExperienceOptions {
  49477. /**
  49478. * Enable or disable default UI to enter XR
  49479. */
  49480. disableDefaultUI?: boolean;
  49481. /**
  49482. * Should teleportation not initialize. defaults to false.
  49483. */
  49484. disableTeleportation?: boolean;
  49485. /**
  49486. * Floor meshes that will be used for teleport
  49487. */
  49488. floorMeshes?: Array<AbstractMesh>;
  49489. /**
  49490. * If set to true, the first frame will not be used to reset position
  49491. * The first frame is mainly used when copying transformation from the old camera
  49492. * Mainly used in AR
  49493. */
  49494. ignoreNativeCameraTransformation?: boolean;
  49495. /**
  49496. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49497. */
  49498. inputOptions?: IWebXRInputOptions;
  49499. /**
  49500. * optional configuration for the output canvas
  49501. */
  49502. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49503. /**
  49504. * optional UI options. This can be used among other to change session mode and reference space type
  49505. */
  49506. uiOptions?: WebXREnterExitUIOptions;
  49507. /**
  49508. * When loading teleportation and pointer select, use stable versions instead of latest.
  49509. */
  49510. useStablePlugins?: boolean;
  49511. /**
  49512. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49513. */
  49514. renderingGroupId?: number;
  49515. /**
  49516. * A list of optional features to init the session with
  49517. * If set to true, all features we support will be added
  49518. */
  49519. optionalFeatures?: boolean | string[];
  49520. }
  49521. /**
  49522. * Default experience which provides a similar setup to the previous webVRExperience
  49523. */
  49524. export class WebXRDefaultExperience {
  49525. /**
  49526. * Base experience
  49527. */
  49528. baseExperience: WebXRExperienceHelper;
  49529. /**
  49530. * Enables ui for entering/exiting xr
  49531. */
  49532. enterExitUI: WebXREnterExitUI;
  49533. /**
  49534. * Input experience extension
  49535. */
  49536. input: WebXRInput;
  49537. /**
  49538. * Enables laser pointer and selection
  49539. */
  49540. pointerSelection: WebXRControllerPointerSelection;
  49541. /**
  49542. * Default target xr should render to
  49543. */
  49544. renderTarget: WebXRRenderTarget;
  49545. /**
  49546. * Enables teleportation
  49547. */
  49548. teleportation: WebXRMotionControllerTeleportation;
  49549. private constructor();
  49550. /**
  49551. * Creates the default xr experience
  49552. * @param scene scene
  49553. * @param options options for basic configuration
  49554. * @returns resulting WebXRDefaultExperience
  49555. */
  49556. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49557. /**
  49558. * DIsposes of the experience helper
  49559. */
  49560. dispose(): void;
  49561. }
  49562. }
  49563. declare module BABYLON {
  49564. /**
  49565. * Options to modify the vr teleportation behavior.
  49566. */
  49567. export interface VRTeleportationOptions {
  49568. /**
  49569. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49570. */
  49571. floorMeshName?: string;
  49572. /**
  49573. * A list of meshes to be used as the teleportation floor. (default: empty)
  49574. */
  49575. floorMeshes?: Mesh[];
  49576. /**
  49577. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49578. */
  49579. teleportationMode?: number;
  49580. /**
  49581. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49582. */
  49583. teleportationTime?: number;
  49584. /**
  49585. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49586. */
  49587. teleportationSpeed?: number;
  49588. /**
  49589. * The easing function used in the animation or null for Linear. (default CircleEase)
  49590. */
  49591. easingFunction?: EasingFunction;
  49592. }
  49593. /**
  49594. * Options to modify the vr experience helper's behavior.
  49595. */
  49596. export interface VRExperienceHelperOptions extends WebVROptions {
  49597. /**
  49598. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49599. */
  49600. createDeviceOrientationCamera?: boolean;
  49601. /**
  49602. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49603. */
  49604. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49605. /**
  49606. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49607. */
  49608. laserToggle?: boolean;
  49609. /**
  49610. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49611. */
  49612. floorMeshes?: Mesh[];
  49613. /**
  49614. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49615. */
  49616. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49617. /**
  49618. * Defines if WebXR should be used instead of WebVR (if available)
  49619. */
  49620. useXR?: boolean;
  49621. }
  49622. /**
  49623. * Event containing information after VR has been entered
  49624. */
  49625. export class OnAfterEnteringVRObservableEvent {
  49626. /**
  49627. * If entering vr was successful
  49628. */
  49629. success: boolean;
  49630. }
  49631. /**
  49632. * Helps to quickly add VR support to an existing scene.
  49633. * See https://doc.babylonjs.com/how_to/webvr_helper
  49634. */
  49635. export class VRExperienceHelper {
  49636. /** Options to modify the vr experience helper's behavior. */
  49637. webVROptions: VRExperienceHelperOptions;
  49638. private _scene;
  49639. private _position;
  49640. private _btnVR;
  49641. private _btnVRDisplayed;
  49642. private _webVRsupported;
  49643. private _webVRready;
  49644. private _webVRrequesting;
  49645. private _webVRpresenting;
  49646. private _hasEnteredVR;
  49647. private _fullscreenVRpresenting;
  49648. private _inputElement;
  49649. private _webVRCamera;
  49650. private _vrDeviceOrientationCamera;
  49651. private _deviceOrientationCamera;
  49652. private _existingCamera;
  49653. private _onKeyDown;
  49654. private _onVrDisplayPresentChange;
  49655. private _onVRDisplayChanged;
  49656. private _onVRRequestPresentStart;
  49657. private _onVRRequestPresentComplete;
  49658. /**
  49659. * 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)
  49660. */
  49661. enableGazeEvenWhenNoPointerLock: boolean;
  49662. /**
  49663. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49664. */
  49665. exitVROnDoubleTap: boolean;
  49666. /**
  49667. * Observable raised right before entering VR.
  49668. */
  49669. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49670. /**
  49671. * Observable raised when entering VR has completed.
  49672. */
  49673. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49674. /**
  49675. * Observable raised when exiting VR.
  49676. */
  49677. onExitingVRObservable: Observable<VRExperienceHelper>;
  49678. /**
  49679. * Observable raised when controller mesh is loaded.
  49680. */
  49681. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49682. /** Return this.onEnteringVRObservable
  49683. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49684. */
  49685. get onEnteringVR(): Observable<VRExperienceHelper>;
  49686. /** Return this.onExitingVRObservable
  49687. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49688. */
  49689. get onExitingVR(): Observable<VRExperienceHelper>;
  49690. /** Return this.onControllerMeshLoadedObservable
  49691. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49692. */
  49693. get onControllerMeshLoaded(): Observable<WebVRController>;
  49694. private _rayLength;
  49695. private _useCustomVRButton;
  49696. private _teleportationRequested;
  49697. private _teleportActive;
  49698. private _floorMeshName;
  49699. private _floorMeshesCollection;
  49700. private _teleportationMode;
  49701. private _teleportationTime;
  49702. private _teleportationSpeed;
  49703. private _teleportationEasing;
  49704. private _rotationAllowed;
  49705. private _teleportBackwardsVector;
  49706. private _teleportationTarget;
  49707. private _isDefaultTeleportationTarget;
  49708. private _postProcessMove;
  49709. private _teleportationFillColor;
  49710. private _teleportationBorderColor;
  49711. private _rotationAngle;
  49712. private _haloCenter;
  49713. private _cameraGazer;
  49714. private _padSensibilityUp;
  49715. private _padSensibilityDown;
  49716. private _leftController;
  49717. private _rightController;
  49718. private _gazeColor;
  49719. private _laserColor;
  49720. private _pickedLaserColor;
  49721. private _pickedGazeColor;
  49722. /**
  49723. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49724. */
  49725. onNewMeshSelected: Observable<AbstractMesh>;
  49726. /**
  49727. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49728. * This observable will provide the mesh and the controller used to select the mesh
  49729. */
  49730. onMeshSelectedWithController: Observable<{
  49731. mesh: AbstractMesh;
  49732. controller: WebVRController;
  49733. }>;
  49734. /**
  49735. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49736. */
  49737. onNewMeshPicked: Observable<PickingInfo>;
  49738. private _circleEase;
  49739. /**
  49740. * Observable raised before camera teleportation
  49741. */
  49742. onBeforeCameraTeleport: Observable<Vector3>;
  49743. /**
  49744. * Observable raised after camera teleportation
  49745. */
  49746. onAfterCameraTeleport: Observable<Vector3>;
  49747. /**
  49748. * Observable raised when current selected mesh gets unselected
  49749. */
  49750. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49751. private _raySelectionPredicate;
  49752. /**
  49753. * To be optionaly changed by user to define custom ray selection
  49754. */
  49755. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49756. /**
  49757. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49758. */
  49759. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49760. /**
  49761. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49762. */
  49763. teleportationEnabled: boolean;
  49764. private _defaultHeight;
  49765. private _teleportationInitialized;
  49766. private _interactionsEnabled;
  49767. private _interactionsRequested;
  49768. private _displayGaze;
  49769. private _displayLaserPointer;
  49770. /**
  49771. * The mesh used to display where the user is going to teleport.
  49772. */
  49773. get teleportationTarget(): Mesh;
  49774. /**
  49775. * Sets the mesh to be used to display where the user is going to teleport.
  49776. */
  49777. set teleportationTarget(value: Mesh);
  49778. /**
  49779. * 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
  49780. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49781. * See https://doc.babylonjs.com/resources/baking_transformations
  49782. */
  49783. get gazeTrackerMesh(): Mesh;
  49784. set gazeTrackerMesh(value: Mesh);
  49785. /**
  49786. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49787. */
  49788. updateGazeTrackerScale: boolean;
  49789. /**
  49790. * If the gaze trackers color should be updated when selecting meshes
  49791. */
  49792. updateGazeTrackerColor: boolean;
  49793. /**
  49794. * If the controller laser color should be updated when selecting meshes
  49795. */
  49796. updateControllerLaserColor: boolean;
  49797. /**
  49798. * The gaze tracking mesh corresponding to the left controller
  49799. */
  49800. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49801. /**
  49802. * The gaze tracking mesh corresponding to the right controller
  49803. */
  49804. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49805. /**
  49806. * If the ray of the gaze should be displayed.
  49807. */
  49808. get displayGaze(): boolean;
  49809. /**
  49810. * Sets if the ray of the gaze should be displayed.
  49811. */
  49812. set displayGaze(value: boolean);
  49813. /**
  49814. * If the ray of the LaserPointer should be displayed.
  49815. */
  49816. get displayLaserPointer(): boolean;
  49817. /**
  49818. * Sets if the ray of the LaserPointer should be displayed.
  49819. */
  49820. set displayLaserPointer(value: boolean);
  49821. /**
  49822. * The deviceOrientationCamera used as the camera when not in VR.
  49823. */
  49824. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49825. /**
  49826. * Based on the current WebVR support, returns the current VR camera used.
  49827. */
  49828. get currentVRCamera(): Nullable<Camera>;
  49829. /**
  49830. * The webVRCamera which is used when in VR.
  49831. */
  49832. get webVRCamera(): WebVRFreeCamera;
  49833. /**
  49834. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49835. */
  49836. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49837. /**
  49838. * The html button that is used to trigger entering into VR.
  49839. */
  49840. get vrButton(): Nullable<HTMLButtonElement>;
  49841. private get _teleportationRequestInitiated();
  49842. /**
  49843. * Defines whether or not Pointer lock should be requested when switching to
  49844. * full screen.
  49845. */
  49846. requestPointerLockOnFullScreen: boolean;
  49847. /**
  49848. * If asking to force XR, this will be populated with the default xr experience
  49849. */
  49850. xr: WebXRDefaultExperience;
  49851. /**
  49852. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49853. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49854. */
  49855. xrTestDone: boolean;
  49856. /**
  49857. * Instantiates a VRExperienceHelper.
  49858. * Helps to quickly add VR support to an existing scene.
  49859. * @param scene The scene the VRExperienceHelper belongs to.
  49860. * @param webVROptions Options to modify the vr experience helper's behavior.
  49861. */
  49862. constructor(scene: Scene,
  49863. /** Options to modify the vr experience helper's behavior. */
  49864. webVROptions?: VRExperienceHelperOptions);
  49865. private completeVRInit;
  49866. private _onDefaultMeshLoaded;
  49867. private _onResize;
  49868. private _onFullscreenChange;
  49869. /**
  49870. * Gets a value indicating if we are currently in VR mode.
  49871. */
  49872. get isInVRMode(): boolean;
  49873. private onVrDisplayPresentChange;
  49874. private onVRDisplayChanged;
  49875. private moveButtonToBottomRight;
  49876. private displayVRButton;
  49877. private updateButtonVisibility;
  49878. private _cachedAngularSensibility;
  49879. /**
  49880. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49881. * Otherwise, will use the fullscreen API.
  49882. */
  49883. enterVR(): void;
  49884. /**
  49885. * Attempt to exit VR, or fullscreen.
  49886. */
  49887. exitVR(): void;
  49888. /**
  49889. * The position of the vr experience helper.
  49890. */
  49891. get position(): Vector3;
  49892. /**
  49893. * Sets the position of the vr experience helper.
  49894. */
  49895. set position(value: Vector3);
  49896. /**
  49897. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49898. */
  49899. enableInteractions(): void;
  49900. private get _noControllerIsActive();
  49901. private beforeRender;
  49902. private _isTeleportationFloor;
  49903. /**
  49904. * Adds a floor mesh to be used for teleportation.
  49905. * @param floorMesh the mesh to be used for teleportation.
  49906. */
  49907. addFloorMesh(floorMesh: Mesh): void;
  49908. /**
  49909. * Removes a floor mesh from being used for teleportation.
  49910. * @param floorMesh the mesh to be removed.
  49911. */
  49912. removeFloorMesh(floorMesh: Mesh): void;
  49913. /**
  49914. * Enables interactions and teleportation using the VR controllers and gaze.
  49915. * @param vrTeleportationOptions options to modify teleportation behavior.
  49916. */
  49917. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49918. private _onNewGamepadConnected;
  49919. private _tryEnableInteractionOnController;
  49920. private _onNewGamepadDisconnected;
  49921. private _enableInteractionOnController;
  49922. private _checkTeleportWithRay;
  49923. private _checkRotate;
  49924. private _checkTeleportBackwards;
  49925. private _enableTeleportationOnController;
  49926. private _createTeleportationCircles;
  49927. private _displayTeleportationTarget;
  49928. private _hideTeleportationTarget;
  49929. private _rotateCamera;
  49930. private _moveTeleportationSelectorTo;
  49931. private _workingVector;
  49932. private _workingQuaternion;
  49933. private _workingMatrix;
  49934. /**
  49935. * Time Constant Teleportation Mode
  49936. */
  49937. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49938. /**
  49939. * Speed Constant Teleportation Mode
  49940. */
  49941. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49942. /**
  49943. * Teleports the users feet to the desired location
  49944. * @param location The location where the user's feet should be placed
  49945. */
  49946. teleportCamera(location: Vector3): void;
  49947. private _convertNormalToDirectionOfRay;
  49948. private _castRayAndSelectObject;
  49949. private _notifySelectedMeshUnselected;
  49950. /**
  49951. * Permanently set new colors for the laser pointer
  49952. * @param color the new laser color
  49953. * @param pickedColor the new laser color when picked mesh detected
  49954. */
  49955. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49956. /**
  49957. * Set lighting enabled / disabled on the laser pointer of both controllers
  49958. * @param enabled should the lighting be enabled on the laser pointer
  49959. */
  49960. setLaserLightingState(enabled?: boolean): void;
  49961. /**
  49962. * Permanently set new colors for the gaze pointer
  49963. * @param color the new gaze color
  49964. * @param pickedColor the new gaze color when picked mesh detected
  49965. */
  49966. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49967. /**
  49968. * Sets the color of the laser ray from the vr controllers.
  49969. * @param color new color for the ray.
  49970. */
  49971. changeLaserColor(color: Color3): void;
  49972. /**
  49973. * Sets the color of the ray from the vr headsets gaze.
  49974. * @param color new color for the ray.
  49975. */
  49976. changeGazeColor(color: Color3): void;
  49977. /**
  49978. * Exits VR and disposes of the vr experience helper
  49979. */
  49980. dispose(): void;
  49981. /**
  49982. * Gets the name of the VRExperienceHelper class
  49983. * @returns "VRExperienceHelper"
  49984. */
  49985. getClassName(): string;
  49986. }
  49987. }
  49988. declare module BABYLON {
  49989. /**
  49990. * Contains an array of blocks representing the octree
  49991. */
  49992. export interface IOctreeContainer<T> {
  49993. /**
  49994. * Blocks within the octree
  49995. */
  49996. blocks: Array<OctreeBlock<T>>;
  49997. }
  49998. /**
  49999. * Class used to store a cell in an octree
  50000. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50001. */
  50002. export class OctreeBlock<T> {
  50003. /**
  50004. * Gets the content of the current block
  50005. */
  50006. entries: T[];
  50007. /**
  50008. * Gets the list of block children
  50009. */
  50010. blocks: Array<OctreeBlock<T>>;
  50011. private _depth;
  50012. private _maxDepth;
  50013. private _capacity;
  50014. private _minPoint;
  50015. private _maxPoint;
  50016. private _boundingVectors;
  50017. private _creationFunc;
  50018. /**
  50019. * Creates a new block
  50020. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50021. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50022. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50023. * @param depth defines the current depth of this block in the octree
  50024. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50025. * @param creationFunc defines a callback to call when an element is added to the block
  50026. */
  50027. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50028. /**
  50029. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50030. */
  50031. get capacity(): number;
  50032. /**
  50033. * Gets the minimum vector (in world space) of the block's bounding box
  50034. */
  50035. get minPoint(): Vector3;
  50036. /**
  50037. * Gets the maximum vector (in world space) of the block's bounding box
  50038. */
  50039. get maxPoint(): Vector3;
  50040. /**
  50041. * Add a new element to this block
  50042. * @param entry defines the element to add
  50043. */
  50044. addEntry(entry: T): void;
  50045. /**
  50046. * Remove an element from this block
  50047. * @param entry defines the element to remove
  50048. */
  50049. removeEntry(entry: T): void;
  50050. /**
  50051. * Add an array of elements to this block
  50052. * @param entries defines the array of elements to add
  50053. */
  50054. addEntries(entries: T[]): void;
  50055. /**
  50056. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50057. * @param frustumPlanes defines the frustum planes to test
  50058. * @param selection defines the array to store current content if selection is positive
  50059. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50060. */
  50061. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50062. /**
  50063. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50064. * @param sphereCenter defines the bounding sphere center
  50065. * @param sphereRadius defines the bounding sphere radius
  50066. * @param selection defines the array to store current content if selection is positive
  50067. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50068. */
  50069. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50070. /**
  50071. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50072. * @param ray defines the ray to test with
  50073. * @param selection defines the array to store current content if selection is positive
  50074. */
  50075. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50076. /**
  50077. * Subdivide the content into child blocks (this block will then be empty)
  50078. */
  50079. createInnerBlocks(): void;
  50080. /**
  50081. * @hidden
  50082. */
  50083. 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;
  50084. }
  50085. }
  50086. declare module BABYLON {
  50087. /**
  50088. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50089. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50090. */
  50091. export class Octree<T> {
  50092. /** 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.) */
  50093. maxDepth: number;
  50094. /**
  50095. * Blocks within the octree containing objects
  50096. */
  50097. blocks: Array<OctreeBlock<T>>;
  50098. /**
  50099. * Content stored in the octree
  50100. */
  50101. dynamicContent: T[];
  50102. private _maxBlockCapacity;
  50103. private _selectionContent;
  50104. private _creationFunc;
  50105. /**
  50106. * Creates a octree
  50107. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50108. * @param creationFunc function to be used to instatiate the octree
  50109. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50110. * @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.)
  50111. */
  50112. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50113. /** 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.) */
  50114. maxDepth?: number);
  50115. /**
  50116. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50117. * @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);
  50118. * @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);
  50119. * @param entries meshes to be added to the octree blocks
  50120. */
  50121. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50122. /**
  50123. * Adds a mesh to the octree
  50124. * @param entry Mesh to add to the octree
  50125. */
  50126. addMesh(entry: T): void;
  50127. /**
  50128. * Remove an element from the octree
  50129. * @param entry defines the element to remove
  50130. */
  50131. removeMesh(entry: T): void;
  50132. /**
  50133. * Selects an array of meshes within the frustum
  50134. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50135. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50136. * @returns array of meshes within the frustum
  50137. */
  50138. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50139. /**
  50140. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50141. * @param sphereCenter defines the bounding sphere center
  50142. * @param sphereRadius defines the bounding sphere radius
  50143. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50144. * @returns an array of objects that intersect the sphere
  50145. */
  50146. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50147. /**
  50148. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50149. * @param ray defines the ray to test with
  50150. * @returns array of intersected objects
  50151. */
  50152. intersectsRay(ray: Ray): SmartArray<T>;
  50153. /**
  50154. * Adds a mesh into the octree block if it intersects the block
  50155. */
  50156. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50157. /**
  50158. * Adds a submesh into the octree block if it intersects the block
  50159. */
  50160. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50161. }
  50162. }
  50163. declare module BABYLON {
  50164. interface Scene {
  50165. /**
  50166. * @hidden
  50167. * Backing Filed
  50168. */
  50169. _selectionOctree: Octree<AbstractMesh>;
  50170. /**
  50171. * Gets the octree used to boost mesh selection (picking)
  50172. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50173. */
  50174. selectionOctree: Octree<AbstractMesh>;
  50175. /**
  50176. * Creates or updates the octree used to boost selection (picking)
  50177. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50178. * @param maxCapacity defines the maximum capacity per leaf
  50179. * @param maxDepth defines the maximum depth of the octree
  50180. * @returns an octree of AbstractMesh
  50181. */
  50182. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50183. }
  50184. interface AbstractMesh {
  50185. /**
  50186. * @hidden
  50187. * Backing Field
  50188. */
  50189. _submeshesOctree: Octree<SubMesh>;
  50190. /**
  50191. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50192. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50193. * @param maxCapacity defines the maximum size of each block (64 by default)
  50194. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50195. * @returns the new octree
  50196. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50197. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50198. */
  50199. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50200. }
  50201. /**
  50202. * Defines the octree scene component responsible to manage any octrees
  50203. * in a given scene.
  50204. */
  50205. export class OctreeSceneComponent {
  50206. /**
  50207. * The component name help to identify the component in the list of scene components.
  50208. */
  50209. readonly name: string;
  50210. /**
  50211. * The scene the component belongs to.
  50212. */
  50213. scene: Scene;
  50214. /**
  50215. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50216. */
  50217. readonly checksIsEnabled: boolean;
  50218. /**
  50219. * Creates a new instance of the component for the given scene
  50220. * @param scene Defines the scene to register the component in
  50221. */
  50222. constructor(scene: Scene);
  50223. /**
  50224. * Registers the component in a given scene
  50225. */
  50226. register(): void;
  50227. /**
  50228. * Return the list of active meshes
  50229. * @returns the list of active meshes
  50230. */
  50231. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50232. /**
  50233. * Return the list of active sub meshes
  50234. * @param mesh The mesh to get the candidates sub meshes from
  50235. * @returns the list of active sub meshes
  50236. */
  50237. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50238. private _tempRay;
  50239. /**
  50240. * Return the list of sub meshes intersecting with a given local ray
  50241. * @param mesh defines the mesh to find the submesh for
  50242. * @param localRay defines the ray in local space
  50243. * @returns the list of intersecting sub meshes
  50244. */
  50245. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50246. /**
  50247. * Return the list of sub meshes colliding with a collider
  50248. * @param mesh defines the mesh to find the submesh for
  50249. * @param collider defines the collider to evaluate the collision against
  50250. * @returns the list of colliding sub meshes
  50251. */
  50252. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50253. /**
  50254. * Rebuilds the elements related to this component in case of
  50255. * context lost for instance.
  50256. */
  50257. rebuild(): void;
  50258. /**
  50259. * Disposes the component and the associated ressources.
  50260. */
  50261. dispose(): void;
  50262. }
  50263. }
  50264. declare module BABYLON {
  50265. /**
  50266. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50267. */
  50268. export class Gizmo implements IDisposable {
  50269. /** The utility layer the gizmo will be added to */
  50270. gizmoLayer: UtilityLayerRenderer;
  50271. /**
  50272. * The root mesh of the gizmo
  50273. */
  50274. _rootMesh: Mesh;
  50275. private _attachedMesh;
  50276. private _attachedNode;
  50277. /**
  50278. * Ratio for the scale of the gizmo (Default: 1)
  50279. */
  50280. scaleRatio: number;
  50281. /**
  50282. * If a custom mesh has been set (Default: false)
  50283. */
  50284. protected _customMeshSet: boolean;
  50285. /**
  50286. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50287. * * When set, interactions will be enabled
  50288. */
  50289. get attachedMesh(): Nullable<AbstractMesh>;
  50290. set attachedMesh(value: Nullable<AbstractMesh>);
  50291. /**
  50292. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50293. * * When set, interactions will be enabled
  50294. */
  50295. get attachedNode(): Nullable<Node>;
  50296. set attachedNode(value: Nullable<Node>);
  50297. /**
  50298. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50299. * @param mesh The mesh to replace the default mesh of the gizmo
  50300. */
  50301. setCustomMesh(mesh: Mesh): void;
  50302. /**
  50303. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50304. */
  50305. updateGizmoRotationToMatchAttachedMesh: boolean;
  50306. /**
  50307. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50308. */
  50309. updateGizmoPositionToMatchAttachedMesh: boolean;
  50310. /**
  50311. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50312. */
  50313. updateScale: boolean;
  50314. protected _interactionsEnabled: boolean;
  50315. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50316. private _beforeRenderObserver;
  50317. private _tempQuaternion;
  50318. private _tempVector;
  50319. private _tempVector2;
  50320. /**
  50321. * Creates a gizmo
  50322. * @param gizmoLayer The utility layer the gizmo will be added to
  50323. */
  50324. constructor(
  50325. /** The utility layer the gizmo will be added to */
  50326. gizmoLayer?: UtilityLayerRenderer);
  50327. /**
  50328. * Updates the gizmo to match the attached mesh's position/rotation
  50329. */
  50330. protected _update(): void;
  50331. /**
  50332. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50333. * @param value Node, TransformNode or mesh
  50334. */
  50335. protected _matrixChanged(): void;
  50336. /**
  50337. * Disposes of the gizmo
  50338. */
  50339. dispose(): void;
  50340. }
  50341. }
  50342. declare module BABYLON {
  50343. /**
  50344. * Single plane drag gizmo
  50345. */
  50346. export class PlaneDragGizmo extends Gizmo {
  50347. /**
  50348. * Drag behavior responsible for the gizmos dragging interactions
  50349. */
  50350. dragBehavior: PointerDragBehavior;
  50351. private _pointerObserver;
  50352. /**
  50353. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50354. */
  50355. snapDistance: number;
  50356. /**
  50357. * Event that fires each time the gizmo snaps to a new location.
  50358. * * snapDistance is the the change in distance
  50359. */
  50360. onSnapObservable: Observable<{
  50361. snapDistance: number;
  50362. }>;
  50363. private _plane;
  50364. private _coloredMaterial;
  50365. private _hoverMaterial;
  50366. private _isEnabled;
  50367. private _parent;
  50368. /** @hidden */
  50369. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50370. /** @hidden */
  50371. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50372. /**
  50373. * Creates a PlaneDragGizmo
  50374. * @param gizmoLayer The utility layer the gizmo will be added to
  50375. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50376. * @param color The color of the gizmo
  50377. */
  50378. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50379. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50380. /**
  50381. * If the gizmo is enabled
  50382. */
  50383. set isEnabled(value: boolean);
  50384. get isEnabled(): boolean;
  50385. /**
  50386. * Disposes of the gizmo
  50387. */
  50388. dispose(): void;
  50389. }
  50390. }
  50391. declare module BABYLON {
  50392. /**
  50393. * Gizmo that enables dragging a mesh along 3 axis
  50394. */
  50395. export class PositionGizmo extends Gizmo {
  50396. /**
  50397. * Internal gizmo used for interactions on the x axis
  50398. */
  50399. xGizmo: AxisDragGizmo;
  50400. /**
  50401. * Internal gizmo used for interactions on the y axis
  50402. */
  50403. yGizmo: AxisDragGizmo;
  50404. /**
  50405. * Internal gizmo used for interactions on the z axis
  50406. */
  50407. zGizmo: AxisDragGizmo;
  50408. /**
  50409. * Internal gizmo used for interactions on the yz plane
  50410. */
  50411. xPlaneGizmo: PlaneDragGizmo;
  50412. /**
  50413. * Internal gizmo used for interactions on the xz plane
  50414. */
  50415. yPlaneGizmo: PlaneDragGizmo;
  50416. /**
  50417. * Internal gizmo used for interactions on the xy plane
  50418. */
  50419. zPlaneGizmo: PlaneDragGizmo;
  50420. /**
  50421. * private variables
  50422. */
  50423. private _meshAttached;
  50424. private _nodeAttached;
  50425. private _updateGizmoRotationToMatchAttachedMesh;
  50426. private _snapDistance;
  50427. private _scaleRatio;
  50428. /** Fires an event when any of it's sub gizmos are dragged */
  50429. onDragStartObservable: Observable<unknown>;
  50430. /** Fires an event when any of it's sub gizmos are released from dragging */
  50431. onDragEndObservable: Observable<unknown>;
  50432. /**
  50433. * If set to true, planar drag is enabled
  50434. */
  50435. private _planarGizmoEnabled;
  50436. get attachedMesh(): Nullable<AbstractMesh>;
  50437. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50438. get attachedNode(): Nullable<Node>;
  50439. set attachedNode(node: Nullable<Node>);
  50440. /**
  50441. * Creates a PositionGizmo
  50442. * @param gizmoLayer The utility layer the gizmo will be added to
  50443. @param thickness display gizmo axis thickness
  50444. */
  50445. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50446. /**
  50447. * If the planar drag gizmo is enabled
  50448. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50449. */
  50450. set planarGizmoEnabled(value: boolean);
  50451. get planarGizmoEnabled(): boolean;
  50452. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50453. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50454. /**
  50455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50456. */
  50457. set snapDistance(value: number);
  50458. get snapDistance(): number;
  50459. /**
  50460. * Ratio for the scale of the gizmo (Default: 1)
  50461. */
  50462. set scaleRatio(value: number);
  50463. get scaleRatio(): number;
  50464. /**
  50465. * Disposes of the gizmo
  50466. */
  50467. dispose(): void;
  50468. /**
  50469. * CustomMeshes are not supported by this gizmo
  50470. * @param mesh The mesh to replace the default mesh of the gizmo
  50471. */
  50472. setCustomMesh(mesh: Mesh): void;
  50473. }
  50474. }
  50475. declare module BABYLON {
  50476. /**
  50477. * Single axis drag gizmo
  50478. */
  50479. export class AxisDragGizmo extends Gizmo {
  50480. /**
  50481. * Drag behavior responsible for the gizmos dragging interactions
  50482. */
  50483. dragBehavior: PointerDragBehavior;
  50484. private _pointerObserver;
  50485. /**
  50486. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50487. */
  50488. snapDistance: number;
  50489. /**
  50490. * Event that fires each time the gizmo snaps to a new location.
  50491. * * snapDistance is the the change in distance
  50492. */
  50493. onSnapObservable: Observable<{
  50494. snapDistance: number;
  50495. }>;
  50496. private _isEnabled;
  50497. private _parent;
  50498. private _arrow;
  50499. private _coloredMaterial;
  50500. private _hoverMaterial;
  50501. /** @hidden */
  50502. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50503. /** @hidden */
  50504. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50505. /**
  50506. * Creates an AxisDragGizmo
  50507. * @param gizmoLayer The utility layer the gizmo will be added to
  50508. * @param dragAxis The axis which the gizmo will be able to drag on
  50509. * @param color The color of the gizmo
  50510. * @param thickness display gizmo axis thickness
  50511. */
  50512. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50513. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50514. /**
  50515. * If the gizmo is enabled
  50516. */
  50517. set isEnabled(value: boolean);
  50518. get isEnabled(): boolean;
  50519. /**
  50520. * Disposes of the gizmo
  50521. */
  50522. dispose(): void;
  50523. }
  50524. }
  50525. declare module BABYLON.Debug {
  50526. /**
  50527. * The Axes viewer will show 3 axes in a specific point in space
  50528. */
  50529. export class AxesViewer {
  50530. private _xAxis;
  50531. private _yAxis;
  50532. private _zAxis;
  50533. private _scaleLinesFactor;
  50534. private _instanced;
  50535. /**
  50536. * Gets the hosting scene
  50537. */
  50538. scene: Scene;
  50539. /**
  50540. * Gets or sets a number used to scale line length
  50541. */
  50542. scaleLines: number;
  50543. /** Gets the node hierarchy used to render x-axis */
  50544. get xAxis(): TransformNode;
  50545. /** Gets the node hierarchy used to render y-axis */
  50546. get yAxis(): TransformNode;
  50547. /** Gets the node hierarchy used to render z-axis */
  50548. get zAxis(): TransformNode;
  50549. /**
  50550. * Creates a new AxesViewer
  50551. * @param scene defines the hosting scene
  50552. * @param scaleLines defines a number used to scale line length (1 by default)
  50553. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50554. * @param xAxis defines the node hierarchy used to render the x-axis
  50555. * @param yAxis defines the node hierarchy used to render the y-axis
  50556. * @param zAxis defines the node hierarchy used to render the z-axis
  50557. */
  50558. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50559. /**
  50560. * Force the viewer to update
  50561. * @param position defines the position of the viewer
  50562. * @param xaxis defines the x axis of the viewer
  50563. * @param yaxis defines the y axis of the viewer
  50564. * @param zaxis defines the z axis of the viewer
  50565. */
  50566. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50567. /**
  50568. * Creates an instance of this axes viewer.
  50569. * @returns a new axes viewer with instanced meshes
  50570. */
  50571. createInstance(): AxesViewer;
  50572. /** Releases resources */
  50573. dispose(): void;
  50574. private static _SetRenderingGroupId;
  50575. }
  50576. }
  50577. declare module BABYLON.Debug {
  50578. /**
  50579. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50580. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50581. */
  50582. export class BoneAxesViewer extends AxesViewer {
  50583. /**
  50584. * Gets or sets the target mesh where to display the axes viewer
  50585. */
  50586. mesh: Nullable<Mesh>;
  50587. /**
  50588. * Gets or sets the target bone where to display the axes viewer
  50589. */
  50590. bone: Nullable<Bone>;
  50591. /** Gets current position */
  50592. pos: Vector3;
  50593. /** Gets direction of X axis */
  50594. xaxis: Vector3;
  50595. /** Gets direction of Y axis */
  50596. yaxis: Vector3;
  50597. /** Gets direction of Z axis */
  50598. zaxis: Vector3;
  50599. /**
  50600. * Creates a new BoneAxesViewer
  50601. * @param scene defines the hosting scene
  50602. * @param bone defines the target bone
  50603. * @param mesh defines the target mesh
  50604. * @param scaleLines defines a scaling factor for line length (1 by default)
  50605. */
  50606. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50607. /**
  50608. * Force the viewer to update
  50609. */
  50610. update(): void;
  50611. /** Releases resources */
  50612. dispose(): void;
  50613. }
  50614. }
  50615. declare module BABYLON {
  50616. /**
  50617. * Interface used to define scene explorer extensibility option
  50618. */
  50619. export interface IExplorerExtensibilityOption {
  50620. /**
  50621. * Define the option label
  50622. */
  50623. label: string;
  50624. /**
  50625. * Defines the action to execute on click
  50626. */
  50627. action: (entity: any) => void;
  50628. }
  50629. /**
  50630. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50631. */
  50632. export interface IExplorerExtensibilityGroup {
  50633. /**
  50634. * Defines a predicate to test if a given type mut be extended
  50635. */
  50636. predicate: (entity: any) => boolean;
  50637. /**
  50638. * Gets the list of options added to a type
  50639. */
  50640. entries: IExplorerExtensibilityOption[];
  50641. }
  50642. /**
  50643. * Interface used to define the options to use to create the Inspector
  50644. */
  50645. export interface IInspectorOptions {
  50646. /**
  50647. * Display in overlay mode (default: false)
  50648. */
  50649. overlay?: boolean;
  50650. /**
  50651. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50652. */
  50653. globalRoot?: HTMLElement;
  50654. /**
  50655. * Display the Scene explorer
  50656. */
  50657. showExplorer?: boolean;
  50658. /**
  50659. * Display the property inspector
  50660. */
  50661. showInspector?: boolean;
  50662. /**
  50663. * Display in embed mode (both panes on the right)
  50664. */
  50665. embedMode?: boolean;
  50666. /**
  50667. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50668. */
  50669. handleResize?: boolean;
  50670. /**
  50671. * Allow the panes to popup (default: true)
  50672. */
  50673. enablePopup?: boolean;
  50674. /**
  50675. * Allow the panes to be closed by users (default: true)
  50676. */
  50677. enableClose?: boolean;
  50678. /**
  50679. * Optional list of extensibility entries
  50680. */
  50681. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50682. /**
  50683. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50684. */
  50685. inspectorURL?: string;
  50686. /**
  50687. * Optional initial tab (default to DebugLayerTab.Properties)
  50688. */
  50689. initialTab?: DebugLayerTab;
  50690. }
  50691. interface Scene {
  50692. /**
  50693. * @hidden
  50694. * Backing field
  50695. */
  50696. _debugLayer: DebugLayer;
  50697. /**
  50698. * Gets the debug layer (aka Inspector) associated with the scene
  50699. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50700. */
  50701. debugLayer: DebugLayer;
  50702. }
  50703. /**
  50704. * Enum of inspector action tab
  50705. */
  50706. export enum DebugLayerTab {
  50707. /**
  50708. * Properties tag (default)
  50709. */
  50710. Properties = 0,
  50711. /**
  50712. * Debug tab
  50713. */
  50714. Debug = 1,
  50715. /**
  50716. * Statistics tab
  50717. */
  50718. Statistics = 2,
  50719. /**
  50720. * Tools tab
  50721. */
  50722. Tools = 3,
  50723. /**
  50724. * Settings tab
  50725. */
  50726. Settings = 4
  50727. }
  50728. /**
  50729. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50730. * what is happening in your scene
  50731. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50732. */
  50733. export class DebugLayer {
  50734. /**
  50735. * Define the url to get the inspector script from.
  50736. * By default it uses the babylonjs CDN.
  50737. * @ignoreNaming
  50738. */
  50739. static InspectorURL: string;
  50740. private _scene;
  50741. private BJSINSPECTOR;
  50742. private _onPropertyChangedObservable?;
  50743. /**
  50744. * Observable triggered when a property is changed through the inspector.
  50745. */
  50746. get onPropertyChangedObservable(): any;
  50747. /**
  50748. * Instantiates a new debug layer.
  50749. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50750. * what is happening in your scene
  50751. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50752. * @param scene Defines the scene to inspect
  50753. */
  50754. constructor(scene: Scene);
  50755. /** Creates the inspector window. */
  50756. private _createInspector;
  50757. /**
  50758. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50759. * @param entity defines the entity to select
  50760. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50761. */
  50762. select(entity: any, lineContainerTitles?: string | string[]): void;
  50763. /** Get the inspector from bundle or global */
  50764. private _getGlobalInspector;
  50765. /**
  50766. * Get if the inspector is visible or not.
  50767. * @returns true if visible otherwise, false
  50768. */
  50769. isVisible(): boolean;
  50770. /**
  50771. * Hide the inspector and close its window.
  50772. */
  50773. hide(): void;
  50774. /**
  50775. * Update the scene in the inspector
  50776. */
  50777. setAsActiveScene(): void;
  50778. /**
  50779. * Launch the debugLayer.
  50780. * @param config Define the configuration of the inspector
  50781. * @return a promise fulfilled when the debug layer is visible
  50782. */
  50783. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50784. }
  50785. }
  50786. declare module BABYLON {
  50787. /**
  50788. * Class containing static functions to help procedurally build meshes
  50789. */
  50790. export class BoxBuilder {
  50791. /**
  50792. * Creates a box mesh
  50793. * * The parameter `size` sets the size (float) of each box side (default 1)
  50794. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50795. * * 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)
  50796. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50798. * * 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
  50799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50800. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50801. * @param name defines the name of the mesh
  50802. * @param options defines the options used to create the mesh
  50803. * @param scene defines the hosting scene
  50804. * @returns the box mesh
  50805. */
  50806. static CreateBox(name: string, options: {
  50807. size?: number;
  50808. width?: number;
  50809. height?: number;
  50810. depth?: number;
  50811. faceUV?: Vector4[];
  50812. faceColors?: Color4[];
  50813. sideOrientation?: number;
  50814. frontUVs?: Vector4;
  50815. backUVs?: Vector4;
  50816. wrap?: boolean;
  50817. topBaseAt?: number;
  50818. bottomBaseAt?: number;
  50819. updatable?: boolean;
  50820. }, scene?: Nullable<Scene>): Mesh;
  50821. }
  50822. }
  50823. declare module BABYLON.Debug {
  50824. /**
  50825. * Used to show the physics impostor around the specific mesh
  50826. */
  50827. export class PhysicsViewer {
  50828. /** @hidden */
  50829. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50830. /** @hidden */
  50831. protected _meshes: Array<Nullable<AbstractMesh>>;
  50832. /** @hidden */
  50833. protected _scene: Nullable<Scene>;
  50834. /** @hidden */
  50835. protected _numMeshes: number;
  50836. /** @hidden */
  50837. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50838. private _renderFunction;
  50839. private _utilityLayer;
  50840. private _debugBoxMesh;
  50841. private _debugSphereMesh;
  50842. private _debugCylinderMesh;
  50843. private _debugMaterial;
  50844. private _debugMeshMeshes;
  50845. /**
  50846. * Creates a new PhysicsViewer
  50847. * @param scene defines the hosting scene
  50848. */
  50849. constructor(scene: Scene);
  50850. /** @hidden */
  50851. protected _updateDebugMeshes(): void;
  50852. /**
  50853. * Renders a specified physic impostor
  50854. * @param impostor defines the impostor to render
  50855. * @param targetMesh defines the mesh represented by the impostor
  50856. * @returns the new debug mesh used to render the impostor
  50857. */
  50858. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50859. /**
  50860. * Hides a specified physic impostor
  50861. * @param impostor defines the impostor to hide
  50862. */
  50863. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50864. private _getDebugMaterial;
  50865. private _getDebugBoxMesh;
  50866. private _getDebugSphereMesh;
  50867. private _getDebugCylinderMesh;
  50868. private _getDebugMeshMesh;
  50869. private _getDebugMesh;
  50870. /** Releases all resources */
  50871. dispose(): void;
  50872. }
  50873. }
  50874. declare module BABYLON {
  50875. /**
  50876. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50877. * in order to better appreciate the issue one might have.
  50878. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50879. */
  50880. export class RayHelper {
  50881. /**
  50882. * Defines the ray we are currently tryin to visualize.
  50883. */
  50884. ray: Nullable<Ray>;
  50885. private _renderPoints;
  50886. private _renderLine;
  50887. private _renderFunction;
  50888. private _scene;
  50889. private _onAfterRenderObserver;
  50890. private _onAfterStepObserver;
  50891. private _attachedToMesh;
  50892. private _meshSpaceDirection;
  50893. private _meshSpaceOrigin;
  50894. /**
  50895. * Helper function to create a colored helper in a scene in one line.
  50896. * @param ray Defines the ray we are currently tryin to visualize
  50897. * @param scene Defines the scene the ray is used in
  50898. * @param color Defines the color we want to see the ray in
  50899. * @returns The newly created ray helper.
  50900. */
  50901. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50902. /**
  50903. * Instantiate a new ray helper.
  50904. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50905. * in order to better appreciate the issue one might have.
  50906. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50907. * @param ray Defines the ray we are currently tryin to visualize
  50908. */
  50909. constructor(ray: Ray);
  50910. /**
  50911. * Shows the ray we are willing to debug.
  50912. * @param scene Defines the scene the ray needs to be rendered in
  50913. * @param color Defines the color the ray needs to be rendered in
  50914. */
  50915. show(scene: Scene, color?: Color3): void;
  50916. /**
  50917. * Hides the ray we are debugging.
  50918. */
  50919. hide(): void;
  50920. private _render;
  50921. /**
  50922. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50923. * @param mesh Defines the mesh we want the helper attached to
  50924. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50925. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50926. * @param length Defines the length of the ray
  50927. */
  50928. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50929. /**
  50930. * Detach the ray helper from the mesh it has previously been attached to.
  50931. */
  50932. detachFromMesh(): void;
  50933. private _updateToMesh;
  50934. /**
  50935. * Dispose the helper and release its associated resources.
  50936. */
  50937. dispose(): void;
  50938. }
  50939. }
  50940. declare module BABYLON {
  50941. /**
  50942. * Defines the options associated with the creation of a SkeletonViewer.
  50943. */
  50944. export interface ISkeletonViewerOptions {
  50945. /** Should the system pause animations before building the Viewer? */
  50946. pauseAnimations: boolean;
  50947. /** Should the system return the skeleton to rest before building? */
  50948. returnToRest: boolean;
  50949. /** public Display Mode of the Viewer */
  50950. displayMode: number;
  50951. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50952. displayOptions: ISkeletonViewerDisplayOptions;
  50953. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50954. computeBonesUsingShaders: boolean;
  50955. }
  50956. /**
  50957. * Defines how to display the various bone meshes for the viewer.
  50958. */
  50959. export interface ISkeletonViewerDisplayOptions {
  50960. /** How far down to start tapering the bone spurs */
  50961. midStep?: number;
  50962. /** How big is the midStep? */
  50963. midStepFactor?: number;
  50964. /** Base for the Sphere Size */
  50965. sphereBaseSize?: number;
  50966. /** The ratio of the sphere to the longest bone in units */
  50967. sphereScaleUnit?: number;
  50968. /** Ratio for the Sphere Size */
  50969. sphereFactor?: number;
  50970. }
  50971. }
  50972. declare module BABYLON {
  50973. /**
  50974. * Class containing static functions to help procedurally build meshes
  50975. */
  50976. export class RibbonBuilder {
  50977. /**
  50978. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50979. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50980. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50981. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50982. * * 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
  50983. * * 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
  50984. * * 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
  50985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50986. * * 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
  50987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50988. * * 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
  50989. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50990. * * 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
  50991. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50993. * @param name defines the name of the mesh
  50994. * @param options defines the options used to create the mesh
  50995. * @param scene defines the hosting scene
  50996. * @returns the ribbon mesh
  50997. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50998. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50999. */
  51000. static CreateRibbon(name: string, options: {
  51001. pathArray: Vector3[][];
  51002. closeArray?: boolean;
  51003. closePath?: boolean;
  51004. offset?: number;
  51005. updatable?: boolean;
  51006. sideOrientation?: number;
  51007. frontUVs?: Vector4;
  51008. backUVs?: Vector4;
  51009. instance?: Mesh;
  51010. invertUV?: boolean;
  51011. uvs?: Vector2[];
  51012. colors?: Color4[];
  51013. }, scene?: Nullable<Scene>): Mesh;
  51014. }
  51015. }
  51016. declare module BABYLON {
  51017. /**
  51018. * Class containing static functions to help procedurally build meshes
  51019. */
  51020. export class ShapeBuilder {
  51021. /**
  51022. * 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.
  51023. * * 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.
  51024. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51025. * * 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.
  51026. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51027. * * 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
  51028. * * 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
  51029. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51031. * * 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
  51032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51034. * @param name defines the name of the mesh
  51035. * @param options defines the options used to create the mesh
  51036. * @param scene defines the hosting scene
  51037. * @returns the extruded shape mesh
  51038. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51040. */
  51041. static ExtrudeShape(name: string, options: {
  51042. shape: Vector3[];
  51043. path: Vector3[];
  51044. scale?: number;
  51045. rotation?: number;
  51046. cap?: number;
  51047. updatable?: boolean;
  51048. sideOrientation?: number;
  51049. frontUVs?: Vector4;
  51050. backUVs?: Vector4;
  51051. instance?: Mesh;
  51052. invertUV?: boolean;
  51053. }, scene?: Nullable<Scene>): Mesh;
  51054. /**
  51055. * Creates an custom extruded shape mesh.
  51056. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51057. * * 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.
  51058. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51059. * * 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
  51060. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51061. * * 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
  51062. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51063. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51064. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51065. * * 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
  51066. * * 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
  51067. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51069. * * 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
  51070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51072. * @param name defines the name of the mesh
  51073. * @param options defines the options used to create the mesh
  51074. * @param scene defines the hosting scene
  51075. * @returns the custom extruded shape mesh
  51076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51079. */
  51080. static ExtrudeShapeCustom(name: string, options: {
  51081. shape: Vector3[];
  51082. path: Vector3[];
  51083. scaleFunction?: any;
  51084. rotationFunction?: any;
  51085. ribbonCloseArray?: boolean;
  51086. ribbonClosePath?: boolean;
  51087. cap?: number;
  51088. updatable?: boolean;
  51089. sideOrientation?: number;
  51090. frontUVs?: Vector4;
  51091. backUVs?: Vector4;
  51092. instance?: Mesh;
  51093. invertUV?: boolean;
  51094. }, scene?: Nullable<Scene>): Mesh;
  51095. private static _ExtrudeShapeGeneric;
  51096. }
  51097. }
  51098. declare module BABYLON.Debug {
  51099. /**
  51100. * Class used to render a debug view of a given skeleton
  51101. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51102. */
  51103. export class SkeletonViewer {
  51104. /** defines the skeleton to render */
  51105. skeleton: Skeleton;
  51106. /** defines the mesh attached to the skeleton */
  51107. mesh: AbstractMesh;
  51108. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51109. autoUpdateBonesMatrices: boolean;
  51110. /** defines the rendering group id to use with the viewer */
  51111. renderingGroupId: number;
  51112. /** is the options for the viewer */
  51113. options: Partial<ISkeletonViewerOptions>;
  51114. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51115. static readonly DISPLAY_LINES: number;
  51116. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51117. static readonly DISPLAY_SPHERES: number;
  51118. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51119. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51120. /** If SkeletonViewer scene scope. */
  51121. private _scene;
  51122. /** Gets or sets the color used to render the skeleton */
  51123. color: Color3;
  51124. /** Array of the points of the skeleton fo the line view. */
  51125. private _debugLines;
  51126. /** The SkeletonViewers Mesh. */
  51127. private _debugMesh;
  51128. /** If SkeletonViewer is enabled. */
  51129. private _isEnabled;
  51130. /** If SkeletonViewer is ready. */
  51131. private _ready;
  51132. /** SkeletonViewer render observable. */
  51133. private _obs;
  51134. /** The Utility Layer to render the gizmos in. */
  51135. private _utilityLayer;
  51136. private _boneIndices;
  51137. /** Gets the Scene. */
  51138. get scene(): Scene;
  51139. /** Gets the utilityLayer. */
  51140. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51141. /** Checks Ready Status. */
  51142. get isReady(): Boolean;
  51143. /** Sets Ready Status. */
  51144. set ready(value: boolean);
  51145. /** Gets the debugMesh */
  51146. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51147. /** Sets the debugMesh */
  51148. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51149. /** Gets the material */
  51150. get material(): StandardMaterial;
  51151. /** Sets the material */
  51152. set material(value: StandardMaterial);
  51153. /** Gets the material */
  51154. get displayMode(): number;
  51155. /** Sets the material */
  51156. set displayMode(value: number);
  51157. /**
  51158. * Creates a new SkeletonViewer
  51159. * @param skeleton defines the skeleton to render
  51160. * @param mesh defines the mesh attached to the skeleton
  51161. * @param scene defines the hosting scene
  51162. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51163. * @param renderingGroupId defines the rendering group id to use with the viewer
  51164. * @param options All of the extra constructor options for the SkeletonViewer
  51165. */
  51166. constructor(
  51167. /** defines the skeleton to render */
  51168. skeleton: Skeleton,
  51169. /** defines the mesh attached to the skeleton */
  51170. mesh: AbstractMesh,
  51171. /** The Scene scope*/
  51172. scene: Scene,
  51173. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51174. autoUpdateBonesMatrices?: boolean,
  51175. /** defines the rendering group id to use with the viewer */
  51176. renderingGroupId?: number,
  51177. /** is the options for the viewer */
  51178. options?: Partial<ISkeletonViewerOptions>);
  51179. /** The Dynamic bindings for the update functions */
  51180. private _bindObs;
  51181. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51182. update(): void;
  51183. /** Gets or sets a boolean indicating if the viewer is enabled */
  51184. set isEnabled(value: boolean);
  51185. get isEnabled(): boolean;
  51186. private _getBonePosition;
  51187. private _getLinesForBonesWithLength;
  51188. private _getLinesForBonesNoLength;
  51189. /** function to revert the mesh and scene back to the initial state. */
  51190. private _revert;
  51191. /** function to build and bind sphere joint points and spur bone representations. */
  51192. private _buildSpheresAndSpurs;
  51193. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51194. private _displayLinesUpdate;
  51195. /** Changes the displayMode of the skeleton viewer
  51196. * @param mode The displayMode numerical value
  51197. */
  51198. changeDisplayMode(mode: number): void;
  51199. /** Changes the displayMode of the skeleton viewer
  51200. * @param option String of the option name
  51201. * @param value The numerical option value
  51202. */
  51203. changeDisplayOptions(option: string, value: number): void;
  51204. /** Release associated resources */
  51205. dispose(): void;
  51206. }
  51207. }
  51208. declare module BABYLON {
  51209. /**
  51210. * Enum for Device Types
  51211. */
  51212. export enum DeviceType {
  51213. /** Generic */
  51214. Generic = 0,
  51215. /** Keyboard */
  51216. Keyboard = 1,
  51217. /** Mouse */
  51218. Mouse = 2,
  51219. /** Touch Pointers */
  51220. Touch = 3,
  51221. /** PS4 Dual Shock */
  51222. DualShock = 4,
  51223. /** Xbox */
  51224. Xbox = 5,
  51225. /** Switch Controller */
  51226. Switch = 6
  51227. }
  51228. /**
  51229. * Enum for All Pointers (Touch/Mouse)
  51230. */
  51231. export enum PointerInput {
  51232. /** Horizontal Axis */
  51233. Horizontal = 0,
  51234. /** Vertical Axis */
  51235. Vertical = 1,
  51236. /** Left Click or Touch */
  51237. LeftClick = 2,
  51238. /** Middle Click */
  51239. MiddleClick = 3,
  51240. /** Right Click */
  51241. RightClick = 4,
  51242. /** Browser Back */
  51243. BrowserBack = 5,
  51244. /** Browser Forward */
  51245. BrowserForward = 6
  51246. }
  51247. /**
  51248. * Enum for Dual Shock Gamepad
  51249. */
  51250. export enum DualShockInput {
  51251. /** Cross */
  51252. Cross = 0,
  51253. /** Circle */
  51254. Circle = 1,
  51255. /** Square */
  51256. Square = 2,
  51257. /** Triangle */
  51258. Triangle = 3,
  51259. /** L1 */
  51260. L1 = 4,
  51261. /** R1 */
  51262. R1 = 5,
  51263. /** L2 */
  51264. L2 = 6,
  51265. /** R2 */
  51266. R2 = 7,
  51267. /** Share */
  51268. Share = 8,
  51269. /** Options */
  51270. Options = 9,
  51271. /** L3 */
  51272. L3 = 10,
  51273. /** R3 */
  51274. R3 = 11,
  51275. /** DPadUp */
  51276. DPadUp = 12,
  51277. /** DPadDown */
  51278. DPadDown = 13,
  51279. /** DPadLeft */
  51280. DPadLeft = 14,
  51281. /** DRight */
  51282. DPadRight = 15,
  51283. /** Home */
  51284. Home = 16,
  51285. /** TouchPad */
  51286. TouchPad = 17,
  51287. /** LStickXAxis */
  51288. LStickXAxis = 18,
  51289. /** LStickYAxis */
  51290. LStickYAxis = 19,
  51291. /** RStickXAxis */
  51292. RStickXAxis = 20,
  51293. /** RStickYAxis */
  51294. RStickYAxis = 21
  51295. }
  51296. /**
  51297. * Enum for Xbox Gamepad
  51298. */
  51299. export enum XboxInput {
  51300. /** A */
  51301. A = 0,
  51302. /** B */
  51303. B = 1,
  51304. /** X */
  51305. X = 2,
  51306. /** Y */
  51307. Y = 3,
  51308. /** LB */
  51309. LB = 4,
  51310. /** RB */
  51311. RB = 5,
  51312. /** LT */
  51313. LT = 6,
  51314. /** RT */
  51315. RT = 7,
  51316. /** Back */
  51317. Back = 8,
  51318. /** Start */
  51319. Start = 9,
  51320. /** LS */
  51321. LS = 10,
  51322. /** RS */
  51323. RS = 11,
  51324. /** DPadUp */
  51325. DPadUp = 12,
  51326. /** DPadDown */
  51327. DPadDown = 13,
  51328. /** DPadLeft */
  51329. DPadLeft = 14,
  51330. /** DRight */
  51331. DPadRight = 15,
  51332. /** Home */
  51333. Home = 16,
  51334. /** LStickXAxis */
  51335. LStickXAxis = 17,
  51336. /** LStickYAxis */
  51337. LStickYAxis = 18,
  51338. /** RStickXAxis */
  51339. RStickXAxis = 19,
  51340. /** RStickYAxis */
  51341. RStickYAxis = 20
  51342. }
  51343. /**
  51344. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51345. */
  51346. export enum SwitchInput {
  51347. /** B */
  51348. B = 0,
  51349. /** A */
  51350. A = 1,
  51351. /** Y */
  51352. Y = 2,
  51353. /** X */
  51354. X = 3,
  51355. /** L */
  51356. L = 4,
  51357. /** R */
  51358. R = 5,
  51359. /** ZL */
  51360. ZL = 6,
  51361. /** ZR */
  51362. ZR = 7,
  51363. /** Minus */
  51364. Minus = 8,
  51365. /** Plus */
  51366. Plus = 9,
  51367. /** LS */
  51368. LS = 10,
  51369. /** RS */
  51370. RS = 11,
  51371. /** DPadUp */
  51372. DPadUp = 12,
  51373. /** DPadDown */
  51374. DPadDown = 13,
  51375. /** DPadLeft */
  51376. DPadLeft = 14,
  51377. /** DRight */
  51378. DPadRight = 15,
  51379. /** Home */
  51380. Home = 16,
  51381. /** Capture */
  51382. Capture = 17,
  51383. /** LStickXAxis */
  51384. LStickXAxis = 18,
  51385. /** LStickYAxis */
  51386. LStickYAxis = 19,
  51387. /** RStickXAxis */
  51388. RStickXAxis = 20,
  51389. /** RStickYAxis */
  51390. RStickYAxis = 21
  51391. }
  51392. }
  51393. declare module BABYLON {
  51394. /**
  51395. * This class will take all inputs from Keyboard, Pointer, and
  51396. * any Gamepads and provide a polling system that all devices
  51397. * will use. This class assumes that there will only be one
  51398. * pointer device and one keyboard.
  51399. */
  51400. export class DeviceInputSystem implements IDisposable {
  51401. /**
  51402. * Callback to be triggered when a device is connected
  51403. */
  51404. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51405. /**
  51406. * Callback to be triggered when a device is disconnected
  51407. */
  51408. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51409. /**
  51410. * Callback to be triggered when event driven input is updated
  51411. */
  51412. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51413. private _inputs;
  51414. private _gamepads;
  51415. private _keyboardActive;
  51416. private _pointerActive;
  51417. private _elementToAttachTo;
  51418. private _keyboardDownEvent;
  51419. private _keyboardUpEvent;
  51420. private _pointerMoveEvent;
  51421. private _pointerDownEvent;
  51422. private _pointerUpEvent;
  51423. private _gamepadConnectedEvent;
  51424. private _gamepadDisconnectedEvent;
  51425. private static _MAX_KEYCODES;
  51426. private static _MAX_POINTER_INPUTS;
  51427. private constructor();
  51428. /**
  51429. * Creates a new DeviceInputSystem instance
  51430. * @param engine Engine to pull input element from
  51431. * @returns The new instance
  51432. */
  51433. static Create(engine: Engine): DeviceInputSystem;
  51434. /**
  51435. * Checks for current device input value, given an id and input index
  51436. * @param deviceName Id of connected device
  51437. * @param inputIndex Index of device input
  51438. * @returns Current value of input
  51439. */
  51440. /**
  51441. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51442. * @param deviceType Enum specifiying device type
  51443. * @param deviceSlot "Slot" or index that device is referenced in
  51444. * @param inputIndex Id of input to be checked
  51445. * @returns Current value of input
  51446. */
  51447. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51448. /**
  51449. * Dispose of all the eventlisteners
  51450. */
  51451. dispose(): void;
  51452. /**
  51453. * Add device and inputs to device array
  51454. * @param deviceType Enum specifiying device type
  51455. * @param deviceSlot "Slot" or index that device is referenced in
  51456. * @param numberOfInputs Number of input entries to create for given device
  51457. */
  51458. private _registerDevice;
  51459. /**
  51460. * Given a specific device name, remove that device from the device map
  51461. * @param deviceType Enum specifiying device type
  51462. * @param deviceSlot "Slot" or index that device is referenced in
  51463. */
  51464. private _unregisterDevice;
  51465. /**
  51466. * Handle all actions that come from keyboard interaction
  51467. */
  51468. private _handleKeyActions;
  51469. /**
  51470. * Handle all actions that come from pointer interaction
  51471. */
  51472. private _handlePointerActions;
  51473. /**
  51474. * Handle all actions that come from gamepad interaction
  51475. */
  51476. private _handleGamepadActions;
  51477. /**
  51478. * Update all non-event based devices with each frame
  51479. * @param deviceType Enum specifiying device type
  51480. * @param deviceSlot "Slot" or index that device is referenced in
  51481. * @param inputIndex Id of input to be checked
  51482. */
  51483. private _updateDevice;
  51484. /**
  51485. * Gets DeviceType from the device name
  51486. * @param deviceName Name of Device from DeviceInputSystem
  51487. * @returns DeviceType enum value
  51488. */
  51489. private _getGamepadDeviceType;
  51490. }
  51491. }
  51492. declare module BABYLON {
  51493. /**
  51494. * Type to handle enforcement of inputs
  51495. */
  51496. 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;
  51497. }
  51498. declare module BABYLON {
  51499. /**
  51500. * Class that handles all input for a specific device
  51501. */
  51502. export class DeviceSource<T extends DeviceType> {
  51503. /** Type of device */
  51504. readonly deviceType: DeviceType;
  51505. /** "Slot" or index that device is referenced in */
  51506. readonly deviceSlot: number;
  51507. /**
  51508. * Observable to handle device input changes per device
  51509. */
  51510. readonly onInputChangedObservable: Observable<{
  51511. inputIndex: DeviceInput<T>;
  51512. previousState: Nullable<number>;
  51513. currentState: Nullable<number>;
  51514. }>;
  51515. private readonly _deviceInputSystem;
  51516. /**
  51517. * Default Constructor
  51518. * @param deviceInputSystem Reference to DeviceInputSystem
  51519. * @param deviceType Type of device
  51520. * @param deviceSlot "Slot" or index that device is referenced in
  51521. */
  51522. constructor(deviceInputSystem: DeviceInputSystem,
  51523. /** Type of device */
  51524. deviceType: DeviceType,
  51525. /** "Slot" or index that device is referenced in */
  51526. deviceSlot?: number);
  51527. /**
  51528. * Get input for specific input
  51529. * @param inputIndex index of specific input on device
  51530. * @returns Input value from DeviceInputSystem
  51531. */
  51532. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51533. }
  51534. /**
  51535. * Class to keep track of devices
  51536. */
  51537. export class DeviceSourceManager implements IDisposable {
  51538. /**
  51539. * Observable to be triggered when before a device is connected
  51540. */
  51541. readonly onBeforeDeviceConnectedObservable: Observable<{
  51542. deviceType: DeviceType;
  51543. deviceSlot: number;
  51544. }>;
  51545. /**
  51546. * Observable to be triggered when before a device is disconnected
  51547. */
  51548. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51549. deviceType: DeviceType;
  51550. deviceSlot: number;
  51551. }>;
  51552. /**
  51553. * Observable to be triggered when after a device is connected
  51554. */
  51555. readonly onAfterDeviceConnectedObservable: Observable<{
  51556. deviceType: DeviceType;
  51557. deviceSlot: number;
  51558. }>;
  51559. /**
  51560. * Observable to be triggered when after a device is disconnected
  51561. */
  51562. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51563. deviceType: DeviceType;
  51564. deviceSlot: number;
  51565. }>;
  51566. private readonly _devices;
  51567. private readonly _firstDevice;
  51568. private readonly _deviceInputSystem;
  51569. /**
  51570. * Default Constructor
  51571. * @param engine engine to pull input element from
  51572. */
  51573. constructor(engine: Engine);
  51574. /**
  51575. * Gets a DeviceSource, given a type and slot
  51576. * @param deviceType Enum specifying device type
  51577. * @param deviceSlot "Slot" or index that device is referenced in
  51578. * @returns DeviceSource object
  51579. */
  51580. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51581. /**
  51582. * Gets an array of DeviceSource objects for a given device type
  51583. * @param deviceType Enum specifying device type
  51584. * @returns Array of DeviceSource objects
  51585. */
  51586. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51587. /**
  51588. * Dispose of DeviceInputSystem and other parts
  51589. */
  51590. dispose(): void;
  51591. /**
  51592. * Function to add device name to device list
  51593. * @param deviceType Enum specifying device type
  51594. * @param deviceSlot "Slot" or index that device is referenced in
  51595. */
  51596. private _addDevice;
  51597. /**
  51598. * Function to remove device name to device list
  51599. * @param deviceType Enum specifying device type
  51600. * @param deviceSlot "Slot" or index that device is referenced in
  51601. */
  51602. private _removeDevice;
  51603. /**
  51604. * Updates array storing first connected device of each type
  51605. * @param type Type of Device
  51606. */
  51607. private _updateFirstDevices;
  51608. }
  51609. }
  51610. declare module BABYLON {
  51611. /**
  51612. * Options to create the null engine
  51613. */
  51614. export class NullEngineOptions {
  51615. /**
  51616. * Render width (Default: 512)
  51617. */
  51618. renderWidth: number;
  51619. /**
  51620. * Render height (Default: 256)
  51621. */
  51622. renderHeight: number;
  51623. /**
  51624. * Texture size (Default: 512)
  51625. */
  51626. textureSize: number;
  51627. /**
  51628. * If delta time between frames should be constant
  51629. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51630. */
  51631. deterministicLockstep: boolean;
  51632. /**
  51633. * Maximum about of steps between frames (Default: 4)
  51634. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51635. */
  51636. lockstepMaxSteps: number;
  51637. /**
  51638. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51639. */
  51640. useHighPrecisionMatrix?: boolean;
  51641. }
  51642. /**
  51643. * The null engine class provides support for headless version of babylon.js.
  51644. * This can be used in server side scenario or for testing purposes
  51645. */
  51646. export class NullEngine extends Engine {
  51647. private _options;
  51648. /**
  51649. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51650. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51651. * @returns true if engine is in deterministic lock step mode
  51652. */
  51653. isDeterministicLockStep(): boolean;
  51654. /**
  51655. * Gets the max steps when engine is running in deterministic lock step
  51656. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51657. * @returns the max steps
  51658. */
  51659. getLockstepMaxSteps(): number;
  51660. /**
  51661. * Gets the current hardware scaling level.
  51662. * By default the hardware scaling level is computed from the window device ratio.
  51663. * 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.
  51664. * @returns a number indicating the current hardware scaling level
  51665. */
  51666. getHardwareScalingLevel(): number;
  51667. constructor(options?: NullEngineOptions);
  51668. /**
  51669. * Creates a vertex buffer
  51670. * @param vertices the data for the vertex buffer
  51671. * @returns the new WebGL static buffer
  51672. */
  51673. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51674. /**
  51675. * Creates a new index buffer
  51676. * @param indices defines the content of the index buffer
  51677. * @param updatable defines if the index buffer must be updatable
  51678. * @returns a new webGL buffer
  51679. */
  51680. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51681. /**
  51682. * Clear the current render buffer or the current render target (if any is set up)
  51683. * @param color defines the color to use
  51684. * @param backBuffer defines if the back buffer must be cleared
  51685. * @param depth defines if the depth buffer must be cleared
  51686. * @param stencil defines if the stencil buffer must be cleared
  51687. */
  51688. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51689. /**
  51690. * Gets the current render width
  51691. * @param useScreen defines if screen size must be used (or the current render target if any)
  51692. * @returns a number defining the current render width
  51693. */
  51694. getRenderWidth(useScreen?: boolean): number;
  51695. /**
  51696. * Gets the current render height
  51697. * @param useScreen defines if screen size must be used (or the current render target if any)
  51698. * @returns a number defining the current render height
  51699. */
  51700. getRenderHeight(useScreen?: boolean): number;
  51701. /**
  51702. * Set the WebGL's viewport
  51703. * @param viewport defines the viewport element to be used
  51704. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51705. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51706. */
  51707. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51708. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51709. /**
  51710. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51711. * @param pipelineContext defines the pipeline context to use
  51712. * @param uniformsNames defines the list of uniform names
  51713. * @returns an array of webGL uniform locations
  51714. */
  51715. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51716. /**
  51717. * Gets the lsit of active attributes for a given webGL program
  51718. * @param pipelineContext defines the pipeline context to use
  51719. * @param attributesNames defines the list of attribute names to get
  51720. * @returns an array of indices indicating the offset of each attribute
  51721. */
  51722. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51723. /**
  51724. * Binds an effect to the webGL context
  51725. * @param effect defines the effect to bind
  51726. */
  51727. bindSamplers(effect: Effect): void;
  51728. /**
  51729. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51730. * @param effect defines the effect to activate
  51731. */
  51732. enableEffect(effect: Effect): void;
  51733. /**
  51734. * Set various states to the webGL context
  51735. * @param culling defines backface culling state
  51736. * @param zOffset defines the value to apply to zOffset (0 by default)
  51737. * @param force defines if states must be applied even if cache is up to date
  51738. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51739. */
  51740. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51741. /**
  51742. * Set the value of an uniform to an array of int32
  51743. * @param uniform defines the webGL uniform location where to store the value
  51744. * @param array defines the array of int32 to store
  51745. */
  51746. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51747. /**
  51748. * Set the value of an uniform to an array of int32 (stored as vec2)
  51749. * @param uniform defines the webGL uniform location where to store the value
  51750. * @param array defines the array of int32 to store
  51751. */
  51752. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51753. /**
  51754. * Set the value of an uniform to an array of int32 (stored as vec3)
  51755. * @param uniform defines the webGL uniform location where to store the value
  51756. * @param array defines the array of int32 to store
  51757. */
  51758. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51759. /**
  51760. * Set the value of an uniform to an array of int32 (stored as vec4)
  51761. * @param uniform defines the webGL uniform location where to store the value
  51762. * @param array defines the array of int32 to store
  51763. */
  51764. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51765. /**
  51766. * Set the value of an uniform to an array of float32
  51767. * @param uniform defines the webGL uniform location where to store the value
  51768. * @param array defines the array of float32 to store
  51769. */
  51770. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51771. /**
  51772. * Set the value of an uniform to an array of float32 (stored as vec2)
  51773. * @param uniform defines the webGL uniform location where to store the value
  51774. * @param array defines the array of float32 to store
  51775. */
  51776. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51777. /**
  51778. * Set the value of an uniform to an array of float32 (stored as vec3)
  51779. * @param uniform defines the webGL uniform location where to store the value
  51780. * @param array defines the array of float32 to store
  51781. */
  51782. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51783. /**
  51784. * Set the value of an uniform to an array of float32 (stored as vec4)
  51785. * @param uniform defines the webGL uniform location where to store the value
  51786. * @param array defines the array of float32 to store
  51787. */
  51788. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51789. /**
  51790. * Set the value of an uniform to an array of number
  51791. * @param uniform defines the webGL uniform location where to store the value
  51792. * @param array defines the array of number to store
  51793. */
  51794. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51795. /**
  51796. * Set the value of an uniform to an array of number (stored as vec2)
  51797. * @param uniform defines the webGL uniform location where to store the value
  51798. * @param array defines the array of number to store
  51799. */
  51800. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51801. /**
  51802. * Set the value of an uniform to an array of number (stored as vec3)
  51803. * @param uniform defines the webGL uniform location where to store the value
  51804. * @param array defines the array of number to store
  51805. */
  51806. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51807. /**
  51808. * Set the value of an uniform to an array of number (stored as vec4)
  51809. * @param uniform defines the webGL uniform location where to store the value
  51810. * @param array defines the array of number to store
  51811. */
  51812. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51813. /**
  51814. * Set the value of an uniform to an array of float32 (stored as matrices)
  51815. * @param uniform defines the webGL uniform location where to store the value
  51816. * @param matrices defines the array of float32 to store
  51817. */
  51818. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51819. /**
  51820. * Set the value of an uniform to a matrix (3x3)
  51821. * @param uniform defines the webGL uniform location where to store the value
  51822. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51823. */
  51824. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51825. /**
  51826. * Set the value of an uniform to a matrix (2x2)
  51827. * @param uniform defines the webGL uniform location where to store the value
  51828. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51829. */
  51830. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51831. /**
  51832. * Set the value of an uniform to a number (float)
  51833. * @param uniform defines the webGL uniform location where to store the value
  51834. * @param value defines the float number to store
  51835. */
  51836. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51837. /**
  51838. * Set the value of an uniform to a vec2
  51839. * @param uniform defines the webGL uniform location where to store the value
  51840. * @param x defines the 1st component of the value
  51841. * @param y defines the 2nd component of the value
  51842. */
  51843. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51844. /**
  51845. * Set the value of an uniform to a vec3
  51846. * @param uniform defines the webGL uniform location where to store the value
  51847. * @param x defines the 1st component of the value
  51848. * @param y defines the 2nd component of the value
  51849. * @param z defines the 3rd component of the value
  51850. */
  51851. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51852. /**
  51853. * Set the value of an uniform to a boolean
  51854. * @param uniform defines the webGL uniform location where to store the value
  51855. * @param bool defines the boolean to store
  51856. */
  51857. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51858. /**
  51859. * Set the value of an uniform to a vec4
  51860. * @param uniform defines the webGL uniform location where to store the value
  51861. * @param x defines the 1st component of the value
  51862. * @param y defines the 2nd component of the value
  51863. * @param z defines the 3rd component of the value
  51864. * @param w defines the 4th component of the value
  51865. */
  51866. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51867. /**
  51868. * Sets the current alpha mode
  51869. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51870. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51871. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51872. */
  51873. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51874. /**
  51875. * Bind webGl buffers directly to the webGL context
  51876. * @param vertexBuffers defines the vertex buffer to bind
  51877. * @param indexBuffer defines the index buffer to bind
  51878. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51879. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51880. * @param effect defines the effect associated with the vertex buffer
  51881. */
  51882. bindBuffers(vertexBuffers: {
  51883. [key: string]: VertexBuffer;
  51884. }, indexBuffer: DataBuffer, effect: Effect): void;
  51885. /**
  51886. * Force the entire cache to be cleared
  51887. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51888. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51889. */
  51890. wipeCaches(bruteForce?: boolean): void;
  51891. /**
  51892. * Send a draw order
  51893. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51894. * @param indexStart defines the starting index
  51895. * @param indexCount defines the number of index to draw
  51896. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51897. */
  51898. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51899. /**
  51900. * Draw a list of indexed primitives
  51901. * @param fillMode defines the primitive to use
  51902. * @param indexStart defines the starting index
  51903. * @param indexCount defines the number of index to draw
  51904. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51905. */
  51906. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51907. /**
  51908. * Draw a list of unindexed primitives
  51909. * @param fillMode defines the primitive to use
  51910. * @param verticesStart defines the index of first vertex to draw
  51911. * @param verticesCount defines the count of vertices to draw
  51912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51913. */
  51914. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51915. /** @hidden */
  51916. _createTexture(): WebGLTexture;
  51917. /** @hidden */
  51918. _releaseTexture(texture: InternalTexture): void;
  51919. /**
  51920. * Usually called from Texture.ts.
  51921. * Passed information to create a WebGLTexture
  51922. * @param urlArg defines a value which contains one of the following:
  51923. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51924. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51925. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51926. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51927. * @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)
  51928. * @param scene needed for loading to the correct scene
  51929. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51930. * @param onLoad optional callback to be called upon successful completion
  51931. * @param onError optional callback to be called upon failure
  51932. * @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
  51933. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51934. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51935. * @param forcedExtension defines the extension to use to pick the right loader
  51936. * @param mimeType defines an optional mime type
  51937. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51938. */
  51939. 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;
  51940. /**
  51941. * Creates a new render target texture
  51942. * @param size defines the size of the texture
  51943. * @param options defines the options used to create the texture
  51944. * @returns a new render target texture stored in an InternalTexture
  51945. */
  51946. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51947. /**
  51948. * Update the sampling mode of a given texture
  51949. * @param samplingMode defines the required sampling mode
  51950. * @param texture defines the texture to update
  51951. */
  51952. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51953. /**
  51954. * Binds the frame buffer to the specified texture.
  51955. * @param texture The texture to render to or null for the default canvas
  51956. * @param faceIndex The face of the texture to render to in case of cube texture
  51957. * @param requiredWidth The width of the target to render to
  51958. * @param requiredHeight The height of the target to render to
  51959. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51960. * @param lodLevel defines le lod level to bind to the frame buffer
  51961. */
  51962. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51963. /**
  51964. * Unbind the current render target texture from the webGL context
  51965. * @param texture defines the render target texture to unbind
  51966. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51967. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51968. */
  51969. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51970. /**
  51971. * Creates a dynamic vertex buffer
  51972. * @param vertices the data for the dynamic vertex buffer
  51973. * @returns the new WebGL dynamic buffer
  51974. */
  51975. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51976. /**
  51977. * Update the content of a dynamic texture
  51978. * @param texture defines the texture to update
  51979. * @param canvas defines the canvas containing the source
  51980. * @param invertY defines if data must be stored with Y axis inverted
  51981. * @param premulAlpha defines if alpha is stored as premultiplied
  51982. * @param format defines the format of the data
  51983. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51984. */
  51985. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51986. /**
  51987. * Gets a boolean indicating if all created effects are ready
  51988. * @returns true if all effects are ready
  51989. */
  51990. areAllEffectsReady(): boolean;
  51991. /**
  51992. * @hidden
  51993. * Get the current error code of the webGL context
  51994. * @returns the error code
  51995. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51996. */
  51997. getError(): number;
  51998. /** @hidden */
  51999. _getUnpackAlignement(): number;
  52000. /** @hidden */
  52001. _unpackFlipY(value: boolean): void;
  52002. /**
  52003. * Update a dynamic index buffer
  52004. * @param indexBuffer defines the target index buffer
  52005. * @param indices defines the data to update
  52006. * @param offset defines the offset in the target index buffer where update should start
  52007. */
  52008. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52009. /**
  52010. * Updates a dynamic vertex buffer.
  52011. * @param vertexBuffer the vertex buffer to update
  52012. * @param vertices the data used to update the vertex buffer
  52013. * @param byteOffset the byte offset of the data (optional)
  52014. * @param byteLength the byte length of the data (optional)
  52015. */
  52016. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52017. /** @hidden */
  52018. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52019. /** @hidden */
  52020. _bindTexture(channel: number, texture: InternalTexture): void;
  52021. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52022. /**
  52023. * 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
  52024. */
  52025. releaseEffects(): void;
  52026. displayLoadingUI(): void;
  52027. hideLoadingUI(): void;
  52028. /** @hidden */
  52029. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52030. /** @hidden */
  52031. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52032. /** @hidden */
  52033. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52034. /** @hidden */
  52035. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52036. }
  52037. }
  52038. declare module BABYLON {
  52039. /**
  52040. * @hidden
  52041. **/
  52042. export class _TimeToken {
  52043. _startTimeQuery: Nullable<WebGLQuery>;
  52044. _endTimeQuery: Nullable<WebGLQuery>;
  52045. _timeElapsedQuery: Nullable<WebGLQuery>;
  52046. _timeElapsedQueryEnded: boolean;
  52047. }
  52048. }
  52049. declare module BABYLON {
  52050. /** @hidden */
  52051. export class _OcclusionDataStorage {
  52052. /** @hidden */
  52053. occlusionInternalRetryCounter: number;
  52054. /** @hidden */
  52055. isOcclusionQueryInProgress: boolean;
  52056. /** @hidden */
  52057. isOccluded: boolean;
  52058. /** @hidden */
  52059. occlusionRetryCount: number;
  52060. /** @hidden */
  52061. occlusionType: number;
  52062. /** @hidden */
  52063. occlusionQueryAlgorithmType: number;
  52064. }
  52065. interface Engine {
  52066. /**
  52067. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52068. * @return the new query
  52069. */
  52070. createQuery(): WebGLQuery;
  52071. /**
  52072. * Delete and release a webGL query
  52073. * @param query defines the query to delete
  52074. * @return the current engine
  52075. */
  52076. deleteQuery(query: WebGLQuery): Engine;
  52077. /**
  52078. * Check if a given query has resolved and got its value
  52079. * @param query defines the query to check
  52080. * @returns true if the query got its value
  52081. */
  52082. isQueryResultAvailable(query: WebGLQuery): boolean;
  52083. /**
  52084. * Gets the value of a given query
  52085. * @param query defines the query to check
  52086. * @returns the value of the query
  52087. */
  52088. getQueryResult(query: WebGLQuery): number;
  52089. /**
  52090. * Initiates an occlusion query
  52091. * @param algorithmType defines the algorithm to use
  52092. * @param query defines the query to use
  52093. * @returns the current engine
  52094. * @see https://doc.babylonjs.com/features/occlusionquery
  52095. */
  52096. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52097. /**
  52098. * Ends an occlusion query
  52099. * @see https://doc.babylonjs.com/features/occlusionquery
  52100. * @param algorithmType defines the algorithm to use
  52101. * @returns the current engine
  52102. */
  52103. endOcclusionQuery(algorithmType: number): Engine;
  52104. /**
  52105. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52106. * Please note that only one query can be issued at a time
  52107. * @returns a time token used to track the time span
  52108. */
  52109. startTimeQuery(): Nullable<_TimeToken>;
  52110. /**
  52111. * Ends a time query
  52112. * @param token defines the token used to measure the time span
  52113. * @returns the time spent (in ns)
  52114. */
  52115. endTimeQuery(token: _TimeToken): int;
  52116. /** @hidden */
  52117. _currentNonTimestampToken: Nullable<_TimeToken>;
  52118. /** @hidden */
  52119. _createTimeQuery(): WebGLQuery;
  52120. /** @hidden */
  52121. _deleteTimeQuery(query: WebGLQuery): void;
  52122. /** @hidden */
  52123. _getGlAlgorithmType(algorithmType: number): number;
  52124. /** @hidden */
  52125. _getTimeQueryResult(query: WebGLQuery): any;
  52126. /** @hidden */
  52127. _getTimeQueryAvailability(query: WebGLQuery): any;
  52128. }
  52129. interface AbstractMesh {
  52130. /**
  52131. * Backing filed
  52132. * @hidden
  52133. */
  52134. __occlusionDataStorage: _OcclusionDataStorage;
  52135. /**
  52136. * Access property
  52137. * @hidden
  52138. */
  52139. _occlusionDataStorage: _OcclusionDataStorage;
  52140. /**
  52141. * 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.
  52142. * The default value is -1 which means don't break the query and wait till the result
  52143. * @see https://doc.babylonjs.com/features/occlusionquery
  52144. */
  52145. occlusionRetryCount: number;
  52146. /**
  52147. * 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:
  52148. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52149. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52150. * * 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.
  52151. * @see https://doc.babylonjs.com/features/occlusionquery
  52152. */
  52153. occlusionType: number;
  52154. /**
  52155. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52156. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52157. * * 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.
  52158. * @see https://doc.babylonjs.com/features/occlusionquery
  52159. */
  52160. occlusionQueryAlgorithmType: number;
  52161. /**
  52162. * 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
  52163. * @see https://doc.babylonjs.com/features/occlusionquery
  52164. */
  52165. isOccluded: boolean;
  52166. /**
  52167. * Flag to check the progress status of the query
  52168. * @see https://doc.babylonjs.com/features/occlusionquery
  52169. */
  52170. isOcclusionQueryInProgress: boolean;
  52171. }
  52172. }
  52173. declare module BABYLON {
  52174. /** @hidden */
  52175. export var _forceTransformFeedbackToBundle: boolean;
  52176. interface Engine {
  52177. /**
  52178. * Creates a webGL transform feedback object
  52179. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52180. * @returns the webGL transform feedback object
  52181. */
  52182. createTransformFeedback(): WebGLTransformFeedback;
  52183. /**
  52184. * Delete a webGL transform feedback object
  52185. * @param value defines the webGL transform feedback object to delete
  52186. */
  52187. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52188. /**
  52189. * Bind a webGL transform feedback object to the webgl context
  52190. * @param value defines the webGL transform feedback object to bind
  52191. */
  52192. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52193. /**
  52194. * Begins a transform feedback operation
  52195. * @param usePoints defines if points or triangles must be used
  52196. */
  52197. beginTransformFeedback(usePoints: boolean): void;
  52198. /**
  52199. * Ends a transform feedback operation
  52200. */
  52201. endTransformFeedback(): void;
  52202. /**
  52203. * Specify the varyings to use with transform feedback
  52204. * @param program defines the associated webGL program
  52205. * @param value defines the list of strings representing the varying names
  52206. */
  52207. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52208. /**
  52209. * Bind a webGL buffer for a transform feedback operation
  52210. * @param value defines the webGL buffer to bind
  52211. */
  52212. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52213. }
  52214. }
  52215. declare module BABYLON {
  52216. /**
  52217. * Class used to define an additional view for the engine
  52218. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52219. */
  52220. export class EngineView {
  52221. /** Defines the canvas where to render the view */
  52222. target: HTMLCanvasElement;
  52223. /** Defines an optional camera used to render the view (will use active camera else) */
  52224. camera?: Camera;
  52225. }
  52226. interface Engine {
  52227. /**
  52228. * Gets or sets the HTML element to use for attaching events
  52229. */
  52230. inputElement: Nullable<HTMLElement>;
  52231. /**
  52232. * Gets the current engine view
  52233. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52234. */
  52235. activeView: Nullable<EngineView>;
  52236. /** Gets or sets the list of views */
  52237. views: EngineView[];
  52238. /**
  52239. * Register a new child canvas
  52240. * @param canvas defines the canvas to register
  52241. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52242. * @returns the associated view
  52243. */
  52244. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52245. /**
  52246. * Remove a registered child canvas
  52247. * @param canvas defines the canvas to remove
  52248. * @returns the current engine
  52249. */
  52250. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52251. }
  52252. }
  52253. declare module BABYLON {
  52254. interface Engine {
  52255. /** @hidden */
  52256. _excludedCompressedTextures: string[];
  52257. /** @hidden */
  52258. _textureFormatInUse: string;
  52259. /**
  52260. * Gets the list of texture formats supported
  52261. */
  52262. readonly texturesSupported: Array<string>;
  52263. /**
  52264. * Gets the texture format in use
  52265. */
  52266. readonly textureFormatInUse: Nullable<string>;
  52267. /**
  52268. * Set the compressed texture extensions or file names to skip.
  52269. *
  52270. * @param skippedFiles defines the list of those texture files you want to skip
  52271. * Example: [".dds", ".env", "myfile.png"]
  52272. */
  52273. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52274. /**
  52275. * Set the compressed texture format to use, based on the formats you have, and the formats
  52276. * supported by the hardware / browser.
  52277. *
  52278. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52279. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52280. * to API arguments needed to compressed textures. This puts the burden on the container
  52281. * generator to house the arcane code for determining these for current & future formats.
  52282. *
  52283. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52284. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52285. *
  52286. * Note: The result of this call is not taken into account when a texture is base64.
  52287. *
  52288. * @param formatsAvailable defines the list of those format families you have created
  52289. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52290. *
  52291. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52292. * @returns The extension selected.
  52293. */
  52294. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52295. }
  52296. }
  52297. declare module BABYLON {
  52298. /**
  52299. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52300. */
  52301. export interface CubeMapInfo {
  52302. /**
  52303. * The pixel array for the front face.
  52304. * This is stored in format, left to right, up to down format.
  52305. */
  52306. front: Nullable<ArrayBufferView>;
  52307. /**
  52308. * The pixel array for the back face.
  52309. * This is stored in format, left to right, up to down format.
  52310. */
  52311. back: Nullable<ArrayBufferView>;
  52312. /**
  52313. * The pixel array for the left face.
  52314. * This is stored in format, left to right, up to down format.
  52315. */
  52316. left: Nullable<ArrayBufferView>;
  52317. /**
  52318. * The pixel array for the right face.
  52319. * This is stored in format, left to right, up to down format.
  52320. */
  52321. right: Nullable<ArrayBufferView>;
  52322. /**
  52323. * The pixel array for the up face.
  52324. * This is stored in format, left to right, up to down format.
  52325. */
  52326. up: Nullable<ArrayBufferView>;
  52327. /**
  52328. * The pixel array for the down face.
  52329. * This is stored in format, left to right, up to down format.
  52330. */
  52331. down: Nullable<ArrayBufferView>;
  52332. /**
  52333. * The size of the cubemap stored.
  52334. *
  52335. * Each faces will be size * size pixels.
  52336. */
  52337. size: number;
  52338. /**
  52339. * The format of the texture.
  52340. *
  52341. * RGBA, RGB.
  52342. */
  52343. format: number;
  52344. /**
  52345. * The type of the texture data.
  52346. *
  52347. * UNSIGNED_INT, FLOAT.
  52348. */
  52349. type: number;
  52350. /**
  52351. * Specifies whether the texture is in gamma space.
  52352. */
  52353. gammaSpace: boolean;
  52354. }
  52355. /**
  52356. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52357. */
  52358. export class PanoramaToCubeMapTools {
  52359. private static FACE_LEFT;
  52360. private static FACE_RIGHT;
  52361. private static FACE_FRONT;
  52362. private static FACE_BACK;
  52363. private static FACE_DOWN;
  52364. private static FACE_UP;
  52365. /**
  52366. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52367. *
  52368. * @param float32Array The source data.
  52369. * @param inputWidth The width of the input panorama.
  52370. * @param inputHeight The height of the input panorama.
  52371. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52372. * @return The cubemap data
  52373. */
  52374. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52375. private static CreateCubemapTexture;
  52376. private static CalcProjectionSpherical;
  52377. }
  52378. }
  52379. declare module BABYLON {
  52380. /**
  52381. * Helper class dealing with the extraction of spherical polynomial dataArray
  52382. * from a cube map.
  52383. */
  52384. export class CubeMapToSphericalPolynomialTools {
  52385. private static FileFaces;
  52386. /**
  52387. * Converts a texture to the according Spherical Polynomial data.
  52388. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52389. *
  52390. * @param texture The texture to extract the information from.
  52391. * @return The Spherical Polynomial data.
  52392. */
  52393. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52394. /**
  52395. * Converts a cubemap to the according Spherical Polynomial data.
  52396. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52397. *
  52398. * @param cubeInfo The Cube map to extract the information from.
  52399. * @return The Spherical Polynomial data.
  52400. */
  52401. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52402. }
  52403. }
  52404. declare module BABYLON {
  52405. interface BaseTexture {
  52406. /**
  52407. * Get the polynomial representation of the texture data.
  52408. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52409. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52410. */
  52411. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52412. }
  52413. }
  52414. declare module BABYLON {
  52415. /** @hidden */
  52416. export var rgbdEncodePixelShader: {
  52417. name: string;
  52418. shader: string;
  52419. };
  52420. }
  52421. declare module BABYLON {
  52422. /** @hidden */
  52423. export var rgbdDecodePixelShader: {
  52424. name: string;
  52425. shader: string;
  52426. };
  52427. }
  52428. declare module BABYLON {
  52429. /**
  52430. * Raw texture data and descriptor sufficient for WebGL texture upload
  52431. */
  52432. export interface EnvironmentTextureInfo {
  52433. /**
  52434. * Version of the environment map
  52435. */
  52436. version: number;
  52437. /**
  52438. * Width of image
  52439. */
  52440. width: number;
  52441. /**
  52442. * Irradiance information stored in the file.
  52443. */
  52444. irradiance: any;
  52445. /**
  52446. * Specular information stored in the file.
  52447. */
  52448. specular: any;
  52449. }
  52450. /**
  52451. * Defines One Image in the file. It requires only the position in the file
  52452. * as well as the length.
  52453. */
  52454. interface BufferImageData {
  52455. /**
  52456. * Length of the image data.
  52457. */
  52458. length: number;
  52459. /**
  52460. * Position of the data from the null terminator delimiting the end of the JSON.
  52461. */
  52462. position: number;
  52463. }
  52464. /**
  52465. * Defines the specular data enclosed in the file.
  52466. * This corresponds to the version 1 of the data.
  52467. */
  52468. export interface EnvironmentTextureSpecularInfoV1 {
  52469. /**
  52470. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52471. */
  52472. specularDataPosition?: number;
  52473. /**
  52474. * This contains all the images data needed to reconstruct the cubemap.
  52475. */
  52476. mipmaps: Array<BufferImageData>;
  52477. /**
  52478. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52479. */
  52480. lodGenerationScale: number;
  52481. }
  52482. /**
  52483. * Sets of helpers addressing the serialization and deserialization of environment texture
  52484. * stored in a BabylonJS env file.
  52485. * Those files are usually stored as .env files.
  52486. */
  52487. export class EnvironmentTextureTools {
  52488. /**
  52489. * Magic number identifying the env file.
  52490. */
  52491. private static _MagicBytes;
  52492. /**
  52493. * Gets the environment info from an env file.
  52494. * @param data The array buffer containing the .env bytes.
  52495. * @returns the environment file info (the json header) if successfully parsed.
  52496. */
  52497. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52498. /**
  52499. * Creates an environment texture from a loaded cube texture.
  52500. * @param texture defines the cube texture to convert in env file
  52501. * @return a promise containing the environment data if succesfull.
  52502. */
  52503. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52504. /**
  52505. * Creates a JSON representation of the spherical data.
  52506. * @param texture defines the texture containing the polynomials
  52507. * @return the JSON representation of the spherical info
  52508. */
  52509. private static _CreateEnvTextureIrradiance;
  52510. /**
  52511. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52512. * @param data the image data
  52513. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52514. * @return the views described by info providing access to the underlying buffer
  52515. */
  52516. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52517. /**
  52518. * Uploads the texture info contained in the env file to the GPU.
  52519. * @param texture defines the internal texture to upload to
  52520. * @param data defines the data to load
  52521. * @param info defines the texture info retrieved through the GetEnvInfo method
  52522. * @returns a promise
  52523. */
  52524. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52525. private static _OnImageReadyAsync;
  52526. /**
  52527. * Uploads the levels of image data to the GPU.
  52528. * @param texture defines the internal texture to upload to
  52529. * @param imageData defines the array buffer views of image data [mipmap][face]
  52530. * @returns a promise
  52531. */
  52532. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52533. /**
  52534. * Uploads spherical polynomials information to the texture.
  52535. * @param texture defines the texture we are trying to upload the information to
  52536. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52537. */
  52538. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52539. /** @hidden */
  52540. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52541. }
  52542. }
  52543. declare module BABYLON {
  52544. /**
  52545. * Class used to inline functions in shader code
  52546. */
  52547. export class ShaderCodeInliner {
  52548. private static readonly _RegexpFindFunctionNameAndType;
  52549. private _sourceCode;
  52550. private _functionDescr;
  52551. private _numMaxIterations;
  52552. /** Gets or sets the token used to mark the functions to inline */
  52553. inlineToken: string;
  52554. /** Gets or sets the debug mode */
  52555. debug: boolean;
  52556. /** Gets the code after the inlining process */
  52557. get code(): string;
  52558. /**
  52559. * Initializes the inliner
  52560. * @param sourceCode shader code source to inline
  52561. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52562. */
  52563. constructor(sourceCode: string, numMaxIterations?: number);
  52564. /**
  52565. * Start the processing of the shader code
  52566. */
  52567. processCode(): void;
  52568. private _collectFunctions;
  52569. private _processInlining;
  52570. private _extractBetweenMarkers;
  52571. private _skipWhitespaces;
  52572. private _removeComments;
  52573. private _replaceFunctionCallsByCode;
  52574. private _findBackward;
  52575. private _escapeRegExp;
  52576. private _replaceNames;
  52577. }
  52578. }
  52579. declare module BABYLON {
  52580. /**
  52581. * Container for accessors for natively-stored mesh data buffers.
  52582. */
  52583. class NativeDataBuffer extends DataBuffer {
  52584. /**
  52585. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52586. */
  52587. nativeIndexBuffer?: any;
  52588. /**
  52589. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52590. */
  52591. nativeVertexBuffer?: any;
  52592. }
  52593. /** @hidden */
  52594. class NativeTexture extends InternalTexture {
  52595. getInternalTexture(): InternalTexture;
  52596. getViewCount(): number;
  52597. }
  52598. /** @hidden */
  52599. export class NativeEngine extends Engine {
  52600. private readonly _native;
  52601. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52602. private readonly INVALID_HANDLE;
  52603. private _boundBuffersVertexArray;
  52604. getHardwareScalingLevel(): number;
  52605. constructor();
  52606. dispose(): void;
  52607. /**
  52608. * Can be used to override the current requestAnimationFrame requester.
  52609. * @hidden
  52610. */
  52611. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52612. /**
  52613. * Override default engine behavior.
  52614. * @param color
  52615. * @param backBuffer
  52616. * @param depth
  52617. * @param stencil
  52618. */
  52619. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52620. /**
  52621. * Gets host document
  52622. * @returns the host document object
  52623. */
  52624. getHostDocument(): Nullable<Document>;
  52625. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52626. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52627. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52628. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52629. [key: string]: VertexBuffer;
  52630. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52631. bindBuffers(vertexBuffers: {
  52632. [key: string]: VertexBuffer;
  52633. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52634. recordVertexArrayObject(vertexBuffers: {
  52635. [key: string]: VertexBuffer;
  52636. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52637. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52638. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52639. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52640. /**
  52641. * Draw a list of indexed primitives
  52642. * @param fillMode defines the primitive to use
  52643. * @param indexStart defines the starting index
  52644. * @param indexCount defines the number of index to draw
  52645. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52646. */
  52647. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52648. /**
  52649. * Draw a list of unindexed primitives
  52650. * @param fillMode defines the primitive to use
  52651. * @param verticesStart defines the index of first vertex to draw
  52652. * @param verticesCount defines the count of vertices to draw
  52653. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52654. */
  52655. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52656. createPipelineContext(): IPipelineContext;
  52657. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52658. /** @hidden */
  52659. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52660. /** @hidden */
  52661. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52662. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52663. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52664. protected _setProgram(program: WebGLProgram): void;
  52665. _releaseEffect(effect: Effect): void;
  52666. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52667. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52668. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52669. bindSamplers(effect: Effect): void;
  52670. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52671. getRenderWidth(useScreen?: boolean): number;
  52672. getRenderHeight(useScreen?: boolean): number;
  52673. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52674. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52675. /**
  52676. * Set the z offset to apply to current rendering
  52677. * @param value defines the offset to apply
  52678. */
  52679. setZOffset(value: number): void;
  52680. /**
  52681. * Gets the current value of the zOffset
  52682. * @returns the current zOffset state
  52683. */
  52684. getZOffset(): number;
  52685. /**
  52686. * Enable or disable depth buffering
  52687. * @param enable defines the state to set
  52688. */
  52689. setDepthBuffer(enable: boolean): void;
  52690. /**
  52691. * Gets a boolean indicating if depth writing is enabled
  52692. * @returns the current depth writing state
  52693. */
  52694. getDepthWrite(): boolean;
  52695. /**
  52696. * Enable or disable depth writing
  52697. * @param enable defines the state to set
  52698. */
  52699. setDepthWrite(enable: boolean): void;
  52700. /**
  52701. * Enable or disable color writing
  52702. * @param enable defines the state to set
  52703. */
  52704. setColorWrite(enable: boolean): void;
  52705. /**
  52706. * Gets a boolean indicating if color writing is enabled
  52707. * @returns the current color writing state
  52708. */
  52709. getColorWrite(): boolean;
  52710. /**
  52711. * Sets alpha constants used by some alpha blending modes
  52712. * @param r defines the red component
  52713. * @param g defines the green component
  52714. * @param b defines the blue component
  52715. * @param a defines the alpha component
  52716. */
  52717. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52718. /**
  52719. * Sets the current alpha mode
  52720. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52721. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52722. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52723. */
  52724. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52725. /**
  52726. * Gets the current alpha mode
  52727. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52728. * @returns the current alpha mode
  52729. */
  52730. getAlphaMode(): number;
  52731. setInt(uniform: WebGLUniformLocation, int: number): void;
  52732. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52733. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52734. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52735. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52736. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52737. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52738. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52739. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52740. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52741. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52742. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52743. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52744. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52745. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52746. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52747. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52748. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52749. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52750. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52751. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52752. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52753. wipeCaches(bruteForce?: boolean): void;
  52754. _createTexture(): WebGLTexture;
  52755. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52756. /**
  52757. * Usually called from Texture.ts.
  52758. * Passed information to create a WebGLTexture
  52759. * @param url defines a value which contains one of the following:
  52760. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52761. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52762. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52763. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52764. * @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)
  52765. * @param scene needed for loading to the correct scene
  52766. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52767. * @param onLoad optional callback to be called upon successful completion
  52768. * @param onError optional callback to be called upon failure
  52769. * @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
  52770. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52771. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52772. * @param forcedExtension defines the extension to use to pick the right loader
  52773. * @param mimeType defines an optional mime type
  52774. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52775. */
  52776. 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;
  52777. /**
  52778. * Creates a cube texture
  52779. * @param rootUrl defines the url where the files to load is located
  52780. * @param scene defines the current scene
  52781. * @param files defines the list of files to load (1 per face)
  52782. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52783. * @param onLoad defines an optional callback raised when the texture is loaded
  52784. * @param onError defines an optional callback raised if there is an issue to load the texture
  52785. * @param format defines the format of the data
  52786. * @param forcedExtension defines the extension to use to pick the right loader
  52787. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52788. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52789. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52790. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52791. * @returns the cube texture as an InternalTexture
  52792. */
  52793. 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;
  52794. private _getSamplingFilter;
  52795. private static _GetNativeTextureFormat;
  52796. createRenderTargetTexture(size: number | {
  52797. width: number;
  52798. height: number;
  52799. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52800. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52801. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52802. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52803. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52804. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52805. /**
  52806. * Updates a dynamic vertex buffer.
  52807. * @param vertexBuffer the vertex buffer to update
  52808. * @param data the data used to update the vertex buffer
  52809. * @param byteOffset the byte offset of the data (optional)
  52810. * @param byteLength the byte length of the data (optional)
  52811. */
  52812. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52813. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52814. private _updateAnisotropicLevel;
  52815. private _getAddressMode;
  52816. /** @hidden */
  52817. _bindTexture(channel: number, texture: InternalTexture): void;
  52818. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52819. releaseEffects(): void;
  52820. /** @hidden */
  52821. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52822. /** @hidden */
  52823. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52824. /** @hidden */
  52825. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52826. /** @hidden */
  52827. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52828. }
  52829. }
  52830. declare module BABYLON {
  52831. /**
  52832. * Gather the list of clipboard event types as constants.
  52833. */
  52834. export class ClipboardEventTypes {
  52835. /**
  52836. * The clipboard event is fired when a copy command is active (pressed).
  52837. */
  52838. static readonly COPY: number;
  52839. /**
  52840. * The clipboard event is fired when a cut command is active (pressed).
  52841. */
  52842. static readonly CUT: number;
  52843. /**
  52844. * The clipboard event is fired when a paste command is active (pressed).
  52845. */
  52846. static readonly PASTE: number;
  52847. }
  52848. /**
  52849. * This class is used to store clipboard related info for the onClipboardObservable event.
  52850. */
  52851. export class ClipboardInfo {
  52852. /**
  52853. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52854. */
  52855. type: number;
  52856. /**
  52857. * Defines the related dom event
  52858. */
  52859. event: ClipboardEvent;
  52860. /**
  52861. *Creates an instance of ClipboardInfo.
  52862. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52863. * @param event Defines the related dom event
  52864. */
  52865. constructor(
  52866. /**
  52867. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52868. */
  52869. type: number,
  52870. /**
  52871. * Defines the related dom event
  52872. */
  52873. event: ClipboardEvent);
  52874. /**
  52875. * Get the clipboard event's type from the keycode.
  52876. * @param keyCode Defines the keyCode for the current keyboard event.
  52877. * @return {number}
  52878. */
  52879. static GetTypeFromCharacter(keyCode: number): number;
  52880. }
  52881. }
  52882. declare module BABYLON {
  52883. /**
  52884. * Google Daydream controller
  52885. */
  52886. export class DaydreamController extends WebVRController {
  52887. /**
  52888. * Base Url for the controller model.
  52889. */
  52890. static MODEL_BASE_URL: string;
  52891. /**
  52892. * File name for the controller model.
  52893. */
  52894. static MODEL_FILENAME: string;
  52895. /**
  52896. * Gamepad Id prefix used to identify Daydream Controller.
  52897. */
  52898. static readonly GAMEPAD_ID_PREFIX: string;
  52899. /**
  52900. * Creates a new DaydreamController from a gamepad
  52901. * @param vrGamepad the gamepad that the controller should be created from
  52902. */
  52903. constructor(vrGamepad: any);
  52904. /**
  52905. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52906. * @param scene scene in which to add meshes
  52907. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52908. */
  52909. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52910. /**
  52911. * Called once for each button that changed state since the last frame
  52912. * @param buttonIdx Which button index changed
  52913. * @param state New state of the button
  52914. * @param changes Which properties on the state changed since last frame
  52915. */
  52916. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52917. }
  52918. }
  52919. declare module BABYLON {
  52920. /**
  52921. * Gear VR Controller
  52922. */
  52923. export class GearVRController extends WebVRController {
  52924. /**
  52925. * Base Url for the controller model.
  52926. */
  52927. static MODEL_BASE_URL: string;
  52928. /**
  52929. * File name for the controller model.
  52930. */
  52931. static MODEL_FILENAME: string;
  52932. /**
  52933. * Gamepad Id prefix used to identify this controller.
  52934. */
  52935. static readonly GAMEPAD_ID_PREFIX: string;
  52936. private readonly _buttonIndexToObservableNameMap;
  52937. /**
  52938. * Creates a new GearVRController from a gamepad
  52939. * @param vrGamepad the gamepad that the controller should be created from
  52940. */
  52941. constructor(vrGamepad: any);
  52942. /**
  52943. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52944. * @param scene scene in which to add meshes
  52945. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52946. */
  52947. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52948. /**
  52949. * Called once for each button that changed state since the last frame
  52950. * @param buttonIdx Which button index changed
  52951. * @param state New state of the button
  52952. * @param changes Which properties on the state changed since last frame
  52953. */
  52954. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52955. }
  52956. }
  52957. declare module BABYLON {
  52958. /**
  52959. * Generic Controller
  52960. */
  52961. export class GenericController extends WebVRController {
  52962. /**
  52963. * Base Url for the controller model.
  52964. */
  52965. static readonly MODEL_BASE_URL: string;
  52966. /**
  52967. * File name for the controller model.
  52968. */
  52969. static readonly MODEL_FILENAME: string;
  52970. /**
  52971. * Creates a new GenericController from a gamepad
  52972. * @param vrGamepad the gamepad that the controller should be created from
  52973. */
  52974. constructor(vrGamepad: any);
  52975. /**
  52976. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52977. * @param scene scene in which to add meshes
  52978. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52979. */
  52980. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52981. /**
  52982. * Called once for each button that changed state since the last frame
  52983. * @param buttonIdx Which button index changed
  52984. * @param state New state of the button
  52985. * @param changes Which properties on the state changed since last frame
  52986. */
  52987. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52988. }
  52989. }
  52990. declare module BABYLON {
  52991. /**
  52992. * Oculus Touch Controller
  52993. */
  52994. export class OculusTouchController extends WebVRController {
  52995. /**
  52996. * Base Url for the controller model.
  52997. */
  52998. static MODEL_BASE_URL: string;
  52999. /**
  53000. * File name for the left controller model.
  53001. */
  53002. static MODEL_LEFT_FILENAME: string;
  53003. /**
  53004. * File name for the right controller model.
  53005. */
  53006. static MODEL_RIGHT_FILENAME: string;
  53007. /**
  53008. * Base Url for the Quest controller model.
  53009. */
  53010. static QUEST_MODEL_BASE_URL: string;
  53011. /**
  53012. * @hidden
  53013. * If the controllers are running on a device that needs the updated Quest controller models
  53014. */
  53015. static _IsQuest: boolean;
  53016. /**
  53017. * Fired when the secondary trigger on this controller is modified
  53018. */
  53019. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53020. /**
  53021. * Fired when the thumb rest on this controller is modified
  53022. */
  53023. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53024. /**
  53025. * Creates a new OculusTouchController from a gamepad
  53026. * @param vrGamepad the gamepad that the controller should be created from
  53027. */
  53028. constructor(vrGamepad: any);
  53029. /**
  53030. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53031. * @param scene scene in which to add meshes
  53032. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53033. */
  53034. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53035. /**
  53036. * Fired when the A button on this controller is modified
  53037. */
  53038. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53039. /**
  53040. * Fired when the B button on this controller is modified
  53041. */
  53042. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53043. /**
  53044. * Fired when the X button on this controller is modified
  53045. */
  53046. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53047. /**
  53048. * Fired when the Y button on this controller is modified
  53049. */
  53050. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53051. /**
  53052. * Called once for each button that changed state since the last frame
  53053. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53054. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53055. * 2) secondary trigger (same)
  53056. * 3) A (right) X (left), touch, pressed = value
  53057. * 4) B / Y
  53058. * 5) thumb rest
  53059. * @param buttonIdx Which button index changed
  53060. * @param state New state of the button
  53061. * @param changes Which properties on the state changed since last frame
  53062. */
  53063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53064. }
  53065. }
  53066. declare module BABYLON {
  53067. /**
  53068. * Vive Controller
  53069. */
  53070. export class ViveController extends WebVRController {
  53071. /**
  53072. * Base Url for the controller model.
  53073. */
  53074. static MODEL_BASE_URL: string;
  53075. /**
  53076. * File name for the controller model.
  53077. */
  53078. static MODEL_FILENAME: string;
  53079. /**
  53080. * Creates a new ViveController from a gamepad
  53081. * @param vrGamepad the gamepad that the controller should be created from
  53082. */
  53083. constructor(vrGamepad: any);
  53084. /**
  53085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53086. * @param scene scene in which to add meshes
  53087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53088. */
  53089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53090. /**
  53091. * Fired when the left button on this controller is modified
  53092. */
  53093. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53094. /**
  53095. * Fired when the right button on this controller is modified
  53096. */
  53097. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53098. /**
  53099. * Fired when the menu button on this controller is modified
  53100. */
  53101. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53102. /**
  53103. * Called once for each button that changed state since the last frame
  53104. * Vive mapping:
  53105. * 0: touchpad
  53106. * 1: trigger
  53107. * 2: left AND right buttons
  53108. * 3: menu button
  53109. * @param buttonIdx Which button index changed
  53110. * @param state New state of the button
  53111. * @param changes Which properties on the state changed since last frame
  53112. */
  53113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53114. }
  53115. }
  53116. declare module BABYLON {
  53117. /**
  53118. * Defines the WindowsMotionController object that the state of the windows motion controller
  53119. */
  53120. export class WindowsMotionController extends WebVRController {
  53121. /**
  53122. * The base url used to load the left and right controller models
  53123. */
  53124. static MODEL_BASE_URL: string;
  53125. /**
  53126. * The name of the left controller model file
  53127. */
  53128. static MODEL_LEFT_FILENAME: string;
  53129. /**
  53130. * The name of the right controller model file
  53131. */
  53132. static MODEL_RIGHT_FILENAME: string;
  53133. /**
  53134. * The controller name prefix for this controller type
  53135. */
  53136. static readonly GAMEPAD_ID_PREFIX: string;
  53137. /**
  53138. * The controller id pattern for this controller type
  53139. */
  53140. private static readonly GAMEPAD_ID_PATTERN;
  53141. private _loadedMeshInfo;
  53142. protected readonly _mapping: {
  53143. buttons: string[];
  53144. buttonMeshNames: {
  53145. trigger: string;
  53146. menu: string;
  53147. grip: string;
  53148. thumbstick: string;
  53149. trackpad: string;
  53150. };
  53151. buttonObservableNames: {
  53152. trigger: string;
  53153. menu: string;
  53154. grip: string;
  53155. thumbstick: string;
  53156. trackpad: string;
  53157. };
  53158. axisMeshNames: string[];
  53159. pointingPoseMeshName: string;
  53160. };
  53161. /**
  53162. * Fired when the trackpad on this controller is clicked
  53163. */
  53164. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53165. /**
  53166. * Fired when the trackpad on this controller is modified
  53167. */
  53168. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53169. /**
  53170. * The current x and y values of this controller's trackpad
  53171. */
  53172. trackpad: StickValues;
  53173. /**
  53174. * Creates a new WindowsMotionController from a gamepad
  53175. * @param vrGamepad the gamepad that the controller should be created from
  53176. */
  53177. constructor(vrGamepad: any);
  53178. /**
  53179. * Fired when the trigger on this controller is modified
  53180. */
  53181. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53182. /**
  53183. * Fired when the menu button on this controller is modified
  53184. */
  53185. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53186. /**
  53187. * Fired when the grip button on this controller is modified
  53188. */
  53189. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53190. /**
  53191. * Fired when the thumbstick button on this controller is modified
  53192. */
  53193. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53194. /**
  53195. * Fired when the touchpad button on this controller is modified
  53196. */
  53197. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53198. /**
  53199. * Fired when the touchpad values on this controller are modified
  53200. */
  53201. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53202. protected _updateTrackpad(): void;
  53203. /**
  53204. * Called once per frame by the engine.
  53205. */
  53206. update(): void;
  53207. /**
  53208. * Called once for each button that changed state since the last frame
  53209. * @param buttonIdx Which button index changed
  53210. * @param state New state of the button
  53211. * @param changes Which properties on the state changed since last frame
  53212. */
  53213. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53214. /**
  53215. * Moves the buttons on the controller mesh based on their current state
  53216. * @param buttonName the name of the button to move
  53217. * @param buttonValue the value of the button which determines the buttons new position
  53218. */
  53219. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53220. /**
  53221. * Moves the axis on the controller mesh based on its current state
  53222. * @param axis the index of the axis
  53223. * @param axisValue the value of the axis which determines the meshes new position
  53224. * @hidden
  53225. */
  53226. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53227. /**
  53228. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53229. * @param scene scene in which to add meshes
  53230. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53231. */
  53232. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53233. /**
  53234. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53235. * can be transformed by button presses and axes values, based on this._mapping.
  53236. *
  53237. * @param scene scene in which the meshes exist
  53238. * @param meshes list of meshes that make up the controller model to process
  53239. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53240. */
  53241. private processModel;
  53242. private createMeshInfo;
  53243. /**
  53244. * Gets the ray of the controller in the direction the controller is pointing
  53245. * @param length the length the resulting ray should be
  53246. * @returns a ray in the direction the controller is pointing
  53247. */
  53248. getForwardRay(length?: number): Ray;
  53249. /**
  53250. * Disposes of the controller
  53251. */
  53252. dispose(): void;
  53253. }
  53254. /**
  53255. * This class represents a new windows motion controller in XR.
  53256. */
  53257. export class XRWindowsMotionController extends WindowsMotionController {
  53258. /**
  53259. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53260. */
  53261. protected readonly _mapping: {
  53262. buttons: string[];
  53263. buttonMeshNames: {
  53264. trigger: string;
  53265. menu: string;
  53266. grip: string;
  53267. thumbstick: string;
  53268. trackpad: string;
  53269. };
  53270. buttonObservableNames: {
  53271. trigger: string;
  53272. menu: string;
  53273. grip: string;
  53274. thumbstick: string;
  53275. trackpad: string;
  53276. };
  53277. axisMeshNames: string[];
  53278. pointingPoseMeshName: string;
  53279. };
  53280. /**
  53281. * Construct a new XR-Based windows motion controller
  53282. *
  53283. * @param gamepadInfo the gamepad object from the browser
  53284. */
  53285. constructor(gamepadInfo: any);
  53286. /**
  53287. * holds the thumbstick values (X,Y)
  53288. */
  53289. thumbstickValues: StickValues;
  53290. /**
  53291. * Fired when the thumbstick on this controller is clicked
  53292. */
  53293. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53294. /**
  53295. * Fired when the thumbstick on this controller is modified
  53296. */
  53297. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53298. /**
  53299. * Fired when the touchpad button on this controller is modified
  53300. */
  53301. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53302. /**
  53303. * Fired when the touchpad values on this controller are modified
  53304. */
  53305. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53306. /**
  53307. * Fired when the thumbstick button on this controller is modified
  53308. * here to prevent breaking changes
  53309. */
  53310. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53311. /**
  53312. * updating the thumbstick(!) and not the trackpad.
  53313. * This is named this way due to the difference between WebVR and XR and to avoid
  53314. * changing the parent class.
  53315. */
  53316. protected _updateTrackpad(): void;
  53317. /**
  53318. * Disposes the class with joy
  53319. */
  53320. dispose(): void;
  53321. }
  53322. }
  53323. declare module BABYLON {
  53324. /**
  53325. * Class containing static functions to help procedurally build meshes
  53326. */
  53327. export class PolyhedronBuilder {
  53328. /**
  53329. * Creates a polyhedron mesh
  53330. * * 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
  53331. * * The parameter `size` (positive float, default 1) sets the polygon size
  53332. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53333. * * 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`
  53334. * * 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
  53335. * * 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)`)
  53336. * * 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
  53337. * * 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
  53338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53339. * * 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
  53340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53341. * @param name defines the name of the mesh
  53342. * @param options defines the options used to create the mesh
  53343. * @param scene defines the hosting scene
  53344. * @returns the polyhedron mesh
  53345. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53346. */
  53347. static CreatePolyhedron(name: string, options: {
  53348. type?: number;
  53349. size?: number;
  53350. sizeX?: number;
  53351. sizeY?: number;
  53352. sizeZ?: number;
  53353. custom?: any;
  53354. faceUV?: Vector4[];
  53355. faceColors?: Color4[];
  53356. flat?: boolean;
  53357. updatable?: boolean;
  53358. sideOrientation?: number;
  53359. frontUVs?: Vector4;
  53360. backUVs?: Vector4;
  53361. }, scene?: Nullable<Scene>): Mesh;
  53362. }
  53363. }
  53364. declare module BABYLON {
  53365. /**
  53366. * Gizmo that enables scaling a mesh along 3 axis
  53367. */
  53368. export class ScaleGizmo extends Gizmo {
  53369. /**
  53370. * Internal gizmo used for interactions on the x axis
  53371. */
  53372. xGizmo: AxisScaleGizmo;
  53373. /**
  53374. * Internal gizmo used for interactions on the y axis
  53375. */
  53376. yGizmo: AxisScaleGizmo;
  53377. /**
  53378. * Internal gizmo used for interactions on the z axis
  53379. */
  53380. zGizmo: AxisScaleGizmo;
  53381. /**
  53382. * Internal gizmo used to scale all axis equally
  53383. */
  53384. uniformScaleGizmo: AxisScaleGizmo;
  53385. private _meshAttached;
  53386. private _nodeAttached;
  53387. private _updateGizmoRotationToMatchAttachedMesh;
  53388. private _snapDistance;
  53389. private _scaleRatio;
  53390. private _uniformScalingMesh;
  53391. private _octahedron;
  53392. private _sensitivity;
  53393. /** Fires an event when any of it's sub gizmos are dragged */
  53394. onDragStartObservable: Observable<unknown>;
  53395. /** Fires an event when any of it's sub gizmos are released from dragging */
  53396. onDragEndObservable: Observable<unknown>;
  53397. get attachedMesh(): Nullable<AbstractMesh>;
  53398. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53399. get attachedNode(): Nullable<Node>;
  53400. set attachedNode(node: Nullable<Node>);
  53401. /**
  53402. * Creates a ScaleGizmo
  53403. * @param gizmoLayer The utility layer the gizmo will be added to
  53404. * @param thickness display gizmo axis thickness
  53405. */
  53406. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53407. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53408. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53409. /**
  53410. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53411. */
  53412. set snapDistance(value: number);
  53413. get snapDistance(): number;
  53414. /**
  53415. * Ratio for the scale of the gizmo (Default: 1)
  53416. */
  53417. set scaleRatio(value: number);
  53418. get scaleRatio(): number;
  53419. /**
  53420. * Sensitivity factor for dragging (Default: 1)
  53421. */
  53422. set sensitivity(value: number);
  53423. get sensitivity(): number;
  53424. /**
  53425. * Disposes of the gizmo
  53426. */
  53427. dispose(): void;
  53428. }
  53429. }
  53430. declare module BABYLON {
  53431. /**
  53432. * Single axis scale gizmo
  53433. */
  53434. export class AxisScaleGizmo extends Gizmo {
  53435. /**
  53436. * Drag behavior responsible for the gizmos dragging interactions
  53437. */
  53438. dragBehavior: PointerDragBehavior;
  53439. private _pointerObserver;
  53440. /**
  53441. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53442. */
  53443. snapDistance: number;
  53444. /**
  53445. * Event that fires each time the gizmo snaps to a new location.
  53446. * * snapDistance is the the change in distance
  53447. */
  53448. onSnapObservable: Observable<{
  53449. snapDistance: number;
  53450. }>;
  53451. /**
  53452. * If the scaling operation should be done on all axis (default: false)
  53453. */
  53454. uniformScaling: boolean;
  53455. /**
  53456. * Custom sensitivity value for the drag strength
  53457. */
  53458. sensitivity: number;
  53459. private _isEnabled;
  53460. private _parent;
  53461. private _arrow;
  53462. private _coloredMaterial;
  53463. private _hoverMaterial;
  53464. /**
  53465. * Creates an AxisScaleGizmo
  53466. * @param gizmoLayer The utility layer the gizmo will be added to
  53467. * @param dragAxis The axis which the gizmo will be able to scale on
  53468. * @param color The color of the gizmo
  53469. * @param thickness display gizmo axis thickness
  53470. */
  53471. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53472. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53473. /**
  53474. * If the gizmo is enabled
  53475. */
  53476. set isEnabled(value: boolean);
  53477. get isEnabled(): boolean;
  53478. /**
  53479. * Disposes of the gizmo
  53480. */
  53481. dispose(): void;
  53482. /**
  53483. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53484. * @param mesh The mesh to replace the default mesh of the gizmo
  53485. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53486. */
  53487. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53488. }
  53489. }
  53490. declare module BABYLON {
  53491. /**
  53492. * Bounding box gizmo
  53493. */
  53494. export class BoundingBoxGizmo extends Gizmo {
  53495. private _lineBoundingBox;
  53496. private _rotateSpheresParent;
  53497. private _scaleBoxesParent;
  53498. private _boundingDimensions;
  53499. private _renderObserver;
  53500. private _pointerObserver;
  53501. private _scaleDragSpeed;
  53502. private _tmpQuaternion;
  53503. private _tmpVector;
  53504. private _tmpRotationMatrix;
  53505. /**
  53506. * 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)
  53507. */
  53508. ignoreChildren: boolean;
  53509. /**
  53510. * 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)
  53511. */
  53512. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53513. /**
  53514. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53515. */
  53516. rotationSphereSize: number;
  53517. /**
  53518. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53519. */
  53520. scaleBoxSize: number;
  53521. /**
  53522. * 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)
  53523. */
  53524. fixedDragMeshScreenSize: boolean;
  53525. /**
  53526. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53527. */
  53528. fixedDragMeshScreenSizeDistanceFactor: number;
  53529. /**
  53530. * Fired when a rotation sphere or scale box is dragged
  53531. */
  53532. onDragStartObservable: Observable<{}>;
  53533. /**
  53534. * Fired when a scale box is dragged
  53535. */
  53536. onScaleBoxDragObservable: Observable<{}>;
  53537. /**
  53538. * Fired when a scale box drag is ended
  53539. */
  53540. onScaleBoxDragEndObservable: Observable<{}>;
  53541. /**
  53542. * Fired when a rotation sphere is dragged
  53543. */
  53544. onRotationSphereDragObservable: Observable<{}>;
  53545. /**
  53546. * Fired when a rotation sphere drag is ended
  53547. */
  53548. onRotationSphereDragEndObservable: Observable<{}>;
  53549. /**
  53550. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  53551. */
  53552. scalePivot: Nullable<Vector3>;
  53553. /**
  53554. * Mesh used as a pivot to rotate the attached node
  53555. */
  53556. private _anchorMesh;
  53557. private _existingMeshScale;
  53558. private _dragMesh;
  53559. private pointerDragBehavior;
  53560. private coloredMaterial;
  53561. private hoverColoredMaterial;
  53562. /**
  53563. * Sets the color of the bounding box gizmo
  53564. * @param color the color to set
  53565. */
  53566. setColor(color: Color3): void;
  53567. /**
  53568. * Creates an BoundingBoxGizmo
  53569. * @param gizmoLayer The utility layer the gizmo will be added to
  53570. * @param color The color of the gizmo
  53571. */
  53572. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53573. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53574. private _selectNode;
  53575. /**
  53576. * Updates the bounding box information for the Gizmo
  53577. */
  53578. updateBoundingBox(): void;
  53579. private _updateRotationSpheres;
  53580. private _updateScaleBoxes;
  53581. /**
  53582. * Enables rotation on the specified axis and disables rotation on the others
  53583. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53584. */
  53585. setEnabledRotationAxis(axis: string): void;
  53586. /**
  53587. * Enables/disables scaling
  53588. * @param enable if scaling should be enabled
  53589. * @param homogeneousScaling defines if scaling should only be homogeneous
  53590. */
  53591. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53592. private _updateDummy;
  53593. /**
  53594. * Enables a pointer drag behavior on the bounding box of the gizmo
  53595. */
  53596. enableDragBehavior(): void;
  53597. /**
  53598. * Disposes of the gizmo
  53599. */
  53600. dispose(): void;
  53601. /**
  53602. * 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)
  53603. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53604. * @returns the bounding box mesh with the passed in mesh as a child
  53605. */
  53606. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53607. /**
  53608. * CustomMeshes are not supported by this gizmo
  53609. * @param mesh The mesh to replace the default mesh of the gizmo
  53610. */
  53611. setCustomMesh(mesh: Mesh): void;
  53612. }
  53613. }
  53614. declare module BABYLON {
  53615. /**
  53616. * Single plane rotation gizmo
  53617. */
  53618. export class PlaneRotationGizmo extends Gizmo {
  53619. /**
  53620. * Drag behavior responsible for the gizmos dragging interactions
  53621. */
  53622. dragBehavior: PointerDragBehavior;
  53623. private _pointerObserver;
  53624. /**
  53625. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53626. */
  53627. snapDistance: number;
  53628. /**
  53629. * Event that fires each time the gizmo snaps to a new location.
  53630. * * snapDistance is the the change in distance
  53631. */
  53632. onSnapObservable: Observable<{
  53633. snapDistance: number;
  53634. }>;
  53635. private _isEnabled;
  53636. private _parent;
  53637. /**
  53638. * Creates a PlaneRotationGizmo
  53639. * @param gizmoLayer The utility layer the gizmo will be added to
  53640. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53641. * @param color The color of the gizmo
  53642. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53643. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53644. * @param thickness display gizmo axis thickness
  53645. */
  53646. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53647. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53648. /**
  53649. * If the gizmo is enabled
  53650. */
  53651. set isEnabled(value: boolean);
  53652. get isEnabled(): boolean;
  53653. /**
  53654. * Disposes of the gizmo
  53655. */
  53656. dispose(): void;
  53657. }
  53658. }
  53659. declare module BABYLON {
  53660. /**
  53661. * Gizmo that enables rotating a mesh along 3 axis
  53662. */
  53663. export class RotationGizmo extends Gizmo {
  53664. /**
  53665. * Internal gizmo used for interactions on the x axis
  53666. */
  53667. xGizmo: PlaneRotationGizmo;
  53668. /**
  53669. * Internal gizmo used for interactions on the y axis
  53670. */
  53671. yGizmo: PlaneRotationGizmo;
  53672. /**
  53673. * Internal gizmo used for interactions on the z axis
  53674. */
  53675. zGizmo: PlaneRotationGizmo;
  53676. /** Fires an event when any of it's sub gizmos are dragged */
  53677. onDragStartObservable: Observable<unknown>;
  53678. /** Fires an event when any of it's sub gizmos are released from dragging */
  53679. onDragEndObservable: Observable<unknown>;
  53680. private _meshAttached;
  53681. private _nodeAttached;
  53682. get attachedMesh(): Nullable<AbstractMesh>;
  53683. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53684. get attachedNode(): Nullable<Node>;
  53685. set attachedNode(node: Nullable<Node>);
  53686. /**
  53687. * Creates a RotationGizmo
  53688. * @param gizmoLayer The utility layer the gizmo will be added to
  53689. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53690. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53691. * @param thickness display gizmo axis thickness
  53692. */
  53693. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53694. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53695. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53696. /**
  53697. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53698. */
  53699. set snapDistance(value: number);
  53700. get snapDistance(): number;
  53701. /**
  53702. * Ratio for the scale of the gizmo (Default: 1)
  53703. */
  53704. set scaleRatio(value: number);
  53705. get scaleRatio(): number;
  53706. /**
  53707. * Disposes of the gizmo
  53708. */
  53709. dispose(): void;
  53710. /**
  53711. * CustomMeshes are not supported by this gizmo
  53712. * @param mesh The mesh to replace the default mesh of the gizmo
  53713. */
  53714. setCustomMesh(mesh: Mesh): void;
  53715. }
  53716. }
  53717. declare module BABYLON {
  53718. /**
  53719. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53720. */
  53721. export class GizmoManager implements IDisposable {
  53722. private scene;
  53723. /**
  53724. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53725. */
  53726. gizmos: {
  53727. positionGizmo: Nullable<PositionGizmo>;
  53728. rotationGizmo: Nullable<RotationGizmo>;
  53729. scaleGizmo: Nullable<ScaleGizmo>;
  53730. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53731. };
  53732. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53733. clearGizmoOnEmptyPointerEvent: boolean;
  53734. /** Fires an event when the manager is attached to a mesh */
  53735. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53736. /** Fires an event when the manager is attached to a node */
  53737. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53738. private _gizmosEnabled;
  53739. private _pointerObserver;
  53740. private _attachedMesh;
  53741. private _attachedNode;
  53742. private _boundingBoxColor;
  53743. private _defaultUtilityLayer;
  53744. private _defaultKeepDepthUtilityLayer;
  53745. private _thickness;
  53746. /**
  53747. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53748. */
  53749. boundingBoxDragBehavior: SixDofDragBehavior;
  53750. /**
  53751. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53752. */
  53753. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53754. /**
  53755. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53756. */
  53757. attachableNodes: Nullable<Array<Node>>;
  53758. /**
  53759. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53760. */
  53761. usePointerToAttachGizmos: boolean;
  53762. /**
  53763. * Utility layer that the bounding box gizmo belongs to
  53764. */
  53765. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53766. /**
  53767. * Utility layer that all gizmos besides bounding box belong to
  53768. */
  53769. get utilityLayer(): UtilityLayerRenderer;
  53770. /**
  53771. * Instatiates a gizmo manager
  53772. * @param scene the scene to overlay the gizmos on top of
  53773. * @param thickness display gizmo axis thickness
  53774. */
  53775. constructor(scene: Scene, thickness?: number);
  53776. /**
  53777. * Attaches a set of gizmos to the specified mesh
  53778. * @param mesh The mesh the gizmo's should be attached to
  53779. */
  53780. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53781. /**
  53782. * Attaches a set of gizmos to the specified node
  53783. * @param node The node the gizmo's should be attached to
  53784. */
  53785. attachToNode(node: Nullable<Node>): void;
  53786. /**
  53787. * If the position gizmo is enabled
  53788. */
  53789. set positionGizmoEnabled(value: boolean);
  53790. get positionGizmoEnabled(): boolean;
  53791. /**
  53792. * If the rotation gizmo is enabled
  53793. */
  53794. set rotationGizmoEnabled(value: boolean);
  53795. get rotationGizmoEnabled(): boolean;
  53796. /**
  53797. * If the scale gizmo is enabled
  53798. */
  53799. set scaleGizmoEnabled(value: boolean);
  53800. get scaleGizmoEnabled(): boolean;
  53801. /**
  53802. * If the boundingBox gizmo is enabled
  53803. */
  53804. set boundingBoxGizmoEnabled(value: boolean);
  53805. get boundingBoxGizmoEnabled(): boolean;
  53806. /**
  53807. * Disposes of the gizmo manager
  53808. */
  53809. dispose(): void;
  53810. }
  53811. }
  53812. declare module BABYLON {
  53813. /**
  53814. * A directional light is defined by a direction (what a surprise!).
  53815. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53816. * 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.
  53817. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53818. */
  53819. export class DirectionalLight extends ShadowLight {
  53820. private _shadowFrustumSize;
  53821. /**
  53822. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53823. */
  53824. get shadowFrustumSize(): number;
  53825. /**
  53826. * Specifies a fix frustum size for the shadow generation.
  53827. */
  53828. set shadowFrustumSize(value: number);
  53829. private _shadowOrthoScale;
  53830. /**
  53831. * Gets the shadow projection scale against the optimal computed one.
  53832. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53833. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53834. */
  53835. get shadowOrthoScale(): number;
  53836. /**
  53837. * Sets the shadow projection scale against the optimal computed one.
  53838. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53839. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53840. */
  53841. set shadowOrthoScale(value: number);
  53842. /**
  53843. * Automatically compute the projection matrix to best fit (including all the casters)
  53844. * on each frame.
  53845. */
  53846. autoUpdateExtends: boolean;
  53847. /**
  53848. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53849. * on each frame. autoUpdateExtends must be set to true for this to work
  53850. */
  53851. autoCalcShadowZBounds: boolean;
  53852. private _orthoLeft;
  53853. private _orthoRight;
  53854. private _orthoTop;
  53855. private _orthoBottom;
  53856. /**
  53857. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53858. * The directional light is emitted from everywhere in the given direction.
  53859. * It can cast shadows.
  53860. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53861. * @param name The friendly name of the light
  53862. * @param direction The direction of the light
  53863. * @param scene The scene the light belongs to
  53864. */
  53865. constructor(name: string, direction: Vector3, scene: Scene);
  53866. /**
  53867. * Returns the string "DirectionalLight".
  53868. * @return The class name
  53869. */
  53870. getClassName(): string;
  53871. /**
  53872. * Returns the integer 1.
  53873. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53874. */
  53875. getTypeID(): number;
  53876. /**
  53877. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53878. * Returns the DirectionalLight Shadow projection matrix.
  53879. */
  53880. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53881. /**
  53882. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53883. * Returns the DirectionalLight Shadow projection matrix.
  53884. */
  53885. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53886. /**
  53887. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53888. * Returns the DirectionalLight Shadow projection matrix.
  53889. */
  53890. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53891. protected _buildUniformLayout(): void;
  53892. /**
  53893. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53894. * @param effect The effect to update
  53895. * @param lightIndex The index of the light in the effect to update
  53896. * @returns The directional light
  53897. */
  53898. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53899. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53900. /**
  53901. * Gets the minZ used for shadow according to both the scene and the light.
  53902. *
  53903. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53904. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53905. * @param activeCamera The camera we are returning the min for
  53906. * @returns the depth min z
  53907. */
  53908. getDepthMinZ(activeCamera: Camera): number;
  53909. /**
  53910. * Gets the maxZ used for shadow according to both the scene and the light.
  53911. *
  53912. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53913. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53914. * @param activeCamera The camera we are returning the max for
  53915. * @returns the depth max z
  53916. */
  53917. getDepthMaxZ(activeCamera: Camera): number;
  53918. /**
  53919. * Prepares the list of defines specific to the light type.
  53920. * @param defines the list of defines
  53921. * @param lightIndex defines the index of the light for the effect
  53922. */
  53923. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53924. }
  53925. }
  53926. declare module BABYLON {
  53927. /**
  53928. * Class containing static functions to help procedurally build meshes
  53929. */
  53930. export class HemisphereBuilder {
  53931. /**
  53932. * Creates a hemisphere mesh
  53933. * @param name defines the name of the mesh
  53934. * @param options defines the options used to create the mesh
  53935. * @param scene defines the hosting scene
  53936. * @returns the hemisphere mesh
  53937. */
  53938. static CreateHemisphere(name: string, options: {
  53939. segments?: number;
  53940. diameter?: number;
  53941. sideOrientation?: number;
  53942. }, scene: any): Mesh;
  53943. }
  53944. }
  53945. declare module BABYLON {
  53946. /**
  53947. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53948. * These values define a cone of light starting from the position, emitting toward the direction.
  53949. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53950. * and the exponent defines the speed of the decay of the light with distance (reach).
  53951. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53952. */
  53953. export class SpotLight extends ShadowLight {
  53954. private _angle;
  53955. private _innerAngle;
  53956. private _cosHalfAngle;
  53957. private _lightAngleScale;
  53958. private _lightAngleOffset;
  53959. /**
  53960. * Gets the cone angle of the spot light in Radians.
  53961. */
  53962. get angle(): number;
  53963. /**
  53964. * Sets the cone angle of the spot light in Radians.
  53965. */
  53966. set angle(value: number);
  53967. /**
  53968. * Only used in gltf falloff mode, this defines the angle where
  53969. * the directional falloff will start before cutting at angle which could be seen
  53970. * as outer angle.
  53971. */
  53972. get innerAngle(): number;
  53973. /**
  53974. * Only used in gltf falloff mode, this defines the angle where
  53975. * the directional falloff will start before cutting at angle which could be seen
  53976. * as outer angle.
  53977. */
  53978. set innerAngle(value: number);
  53979. private _shadowAngleScale;
  53980. /**
  53981. * Allows scaling the angle of the light for shadow generation only.
  53982. */
  53983. get shadowAngleScale(): number;
  53984. /**
  53985. * Allows scaling the angle of the light for shadow generation only.
  53986. */
  53987. set shadowAngleScale(value: number);
  53988. /**
  53989. * The light decay speed with the distance from the emission spot.
  53990. */
  53991. exponent: number;
  53992. private _projectionTextureMatrix;
  53993. /**
  53994. * Allows reading the projecton texture
  53995. */
  53996. get projectionTextureMatrix(): Matrix;
  53997. protected _projectionTextureLightNear: number;
  53998. /**
  53999. * Gets the near clip of the Spotlight for texture projection.
  54000. */
  54001. get projectionTextureLightNear(): number;
  54002. /**
  54003. * Sets the near clip of the Spotlight for texture projection.
  54004. */
  54005. set projectionTextureLightNear(value: number);
  54006. protected _projectionTextureLightFar: number;
  54007. /**
  54008. * Gets the far clip of the Spotlight for texture projection.
  54009. */
  54010. get projectionTextureLightFar(): number;
  54011. /**
  54012. * Sets the far clip of the Spotlight for texture projection.
  54013. */
  54014. set projectionTextureLightFar(value: number);
  54015. protected _projectionTextureUpDirection: Vector3;
  54016. /**
  54017. * Gets the Up vector of the Spotlight for texture projection.
  54018. */
  54019. get projectionTextureUpDirection(): Vector3;
  54020. /**
  54021. * Sets the Up vector of the Spotlight for texture projection.
  54022. */
  54023. set projectionTextureUpDirection(value: Vector3);
  54024. private _projectionTexture;
  54025. /**
  54026. * Gets the projection texture of the light.
  54027. */
  54028. get projectionTexture(): Nullable<BaseTexture>;
  54029. /**
  54030. * Sets the projection texture of the light.
  54031. */
  54032. set projectionTexture(value: Nullable<BaseTexture>);
  54033. private _projectionTextureViewLightDirty;
  54034. private _projectionTextureProjectionLightDirty;
  54035. private _projectionTextureDirty;
  54036. private _projectionTextureViewTargetVector;
  54037. private _projectionTextureViewLightMatrix;
  54038. private _projectionTextureProjectionLightMatrix;
  54039. private _projectionTextureScalingMatrix;
  54040. /**
  54041. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54042. * It can cast shadows.
  54043. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54044. * @param name The light friendly name
  54045. * @param position The position of the spot light in the scene
  54046. * @param direction The direction of the light in the scene
  54047. * @param angle The cone angle of the light in Radians
  54048. * @param exponent The light decay speed with the distance from the emission spot
  54049. * @param scene The scene the lights belongs to
  54050. */
  54051. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54052. /**
  54053. * Returns the string "SpotLight".
  54054. * @returns the class name
  54055. */
  54056. getClassName(): string;
  54057. /**
  54058. * Returns the integer 2.
  54059. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54060. */
  54061. getTypeID(): number;
  54062. /**
  54063. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54064. */
  54065. protected _setDirection(value: Vector3): void;
  54066. /**
  54067. * Overrides the position setter to recompute the projection texture view light Matrix.
  54068. */
  54069. protected _setPosition(value: Vector3): void;
  54070. /**
  54071. * 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.
  54072. * Returns the SpotLight.
  54073. */
  54074. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54075. protected _computeProjectionTextureViewLightMatrix(): void;
  54076. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54077. /**
  54078. * Main function for light texture projection matrix computing.
  54079. */
  54080. protected _computeProjectionTextureMatrix(): void;
  54081. protected _buildUniformLayout(): void;
  54082. private _computeAngleValues;
  54083. /**
  54084. * Sets the passed Effect "effect" with the Light textures.
  54085. * @param effect The effect to update
  54086. * @param lightIndex The index of the light in the effect to update
  54087. * @returns The light
  54088. */
  54089. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54090. /**
  54091. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54092. * @param effect The effect to update
  54093. * @param lightIndex The index of the light in the effect to update
  54094. * @returns The spot light
  54095. */
  54096. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54097. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54098. /**
  54099. * Disposes the light and the associated resources.
  54100. */
  54101. dispose(): void;
  54102. /**
  54103. * Prepares the list of defines specific to the light type.
  54104. * @param defines the list of defines
  54105. * @param lightIndex defines the index of the light for the effect
  54106. */
  54107. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54108. }
  54109. }
  54110. declare module BABYLON {
  54111. /**
  54112. * Gizmo that enables viewing a light
  54113. */
  54114. export class LightGizmo extends Gizmo {
  54115. private _lightMesh;
  54116. private _material;
  54117. private _cachedPosition;
  54118. private _cachedForward;
  54119. private _attachedMeshParent;
  54120. /**
  54121. * Creates a LightGizmo
  54122. * @param gizmoLayer The utility layer the gizmo will be added to
  54123. */
  54124. constructor(gizmoLayer?: UtilityLayerRenderer);
  54125. private _light;
  54126. /**
  54127. * The light that the gizmo is attached to
  54128. */
  54129. set light(light: Nullable<Light>);
  54130. get light(): Nullable<Light>;
  54131. /**
  54132. * Gets the material used to render the light gizmo
  54133. */
  54134. get material(): StandardMaterial;
  54135. /**
  54136. * @hidden
  54137. * Updates the gizmo to match the attached mesh's position/rotation
  54138. */
  54139. protected _update(): void;
  54140. private static _Scale;
  54141. /**
  54142. * Creates the lines for a light mesh
  54143. */
  54144. private static _CreateLightLines;
  54145. /**
  54146. * Disposes of the light gizmo
  54147. */
  54148. dispose(): void;
  54149. private static _CreateHemisphericLightMesh;
  54150. private static _CreatePointLightMesh;
  54151. private static _CreateSpotLightMesh;
  54152. private static _CreateDirectionalLightMesh;
  54153. }
  54154. }
  54155. declare module BABYLON {
  54156. /**
  54157. * Gizmo that enables viewing a camera
  54158. */
  54159. export class CameraGizmo extends Gizmo {
  54160. private _cameraMesh;
  54161. private _cameraLinesMesh;
  54162. private _material;
  54163. /**
  54164. * Creates a CameraGizmo
  54165. * @param gizmoLayer The utility layer the gizmo will be added to
  54166. */
  54167. constructor(gizmoLayer?: UtilityLayerRenderer);
  54168. private _camera;
  54169. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54170. get displayFrustum(): boolean;
  54171. set displayFrustum(value: boolean);
  54172. /**
  54173. * The camera that the gizmo is attached to
  54174. */
  54175. set camera(camera: Nullable<Camera>);
  54176. get camera(): Nullable<Camera>;
  54177. /**
  54178. * Gets the material used to render the camera gizmo
  54179. */
  54180. get material(): StandardMaterial;
  54181. /**
  54182. * @hidden
  54183. * Updates the gizmo to match the attached mesh's position/rotation
  54184. */
  54185. protected _update(): void;
  54186. private static _Scale;
  54187. private _invProjection;
  54188. /**
  54189. * Disposes of the camera gizmo
  54190. */
  54191. dispose(): void;
  54192. private static _CreateCameraMesh;
  54193. private static _CreateCameraFrustum;
  54194. }
  54195. }
  54196. declare module BABYLON {
  54197. /** @hidden */
  54198. export var backgroundFragmentDeclaration: {
  54199. name: string;
  54200. shader: string;
  54201. };
  54202. }
  54203. declare module BABYLON {
  54204. /** @hidden */
  54205. export var backgroundUboDeclaration: {
  54206. name: string;
  54207. shader: string;
  54208. };
  54209. }
  54210. declare module BABYLON {
  54211. /** @hidden */
  54212. export var backgroundPixelShader: {
  54213. name: string;
  54214. shader: string;
  54215. };
  54216. }
  54217. declare module BABYLON {
  54218. /** @hidden */
  54219. export var backgroundVertexDeclaration: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module BABYLON {
  54225. /** @hidden */
  54226. export var backgroundVertexShader: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module BABYLON {
  54232. /**
  54233. * Background material used to create an efficient environement around your scene.
  54234. */
  54235. export class BackgroundMaterial extends PushMaterial {
  54236. /**
  54237. * Standard reflectance value at parallel view angle.
  54238. */
  54239. static StandardReflectance0: number;
  54240. /**
  54241. * Standard reflectance value at grazing angle.
  54242. */
  54243. static StandardReflectance90: number;
  54244. protected _primaryColor: Color3;
  54245. /**
  54246. * Key light Color (multiply against the environement texture)
  54247. */
  54248. primaryColor: Color3;
  54249. protected __perceptualColor: Nullable<Color3>;
  54250. /**
  54251. * Experimental Internal Use Only.
  54252. *
  54253. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54254. * This acts as a helper to set the primary color to a more "human friendly" value.
  54255. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54256. * output color as close as possible from the chosen value.
  54257. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54258. * part of lighting setup.)
  54259. */
  54260. get _perceptualColor(): Nullable<Color3>;
  54261. set _perceptualColor(value: Nullable<Color3>);
  54262. protected _primaryColorShadowLevel: float;
  54263. /**
  54264. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54265. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54266. */
  54267. get primaryColorShadowLevel(): float;
  54268. set primaryColorShadowLevel(value: float);
  54269. protected _primaryColorHighlightLevel: float;
  54270. /**
  54271. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54272. * The primary color is used at the level chosen to define what the white area would look.
  54273. */
  54274. get primaryColorHighlightLevel(): float;
  54275. set primaryColorHighlightLevel(value: float);
  54276. protected _reflectionTexture: Nullable<BaseTexture>;
  54277. /**
  54278. * Reflection Texture used in the material.
  54279. * Should be author in a specific way for the best result (refer to the documentation).
  54280. */
  54281. reflectionTexture: Nullable<BaseTexture>;
  54282. protected _reflectionBlur: float;
  54283. /**
  54284. * Reflection Texture level of blur.
  54285. *
  54286. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54287. * texture twice.
  54288. */
  54289. reflectionBlur: float;
  54290. protected _diffuseTexture: Nullable<BaseTexture>;
  54291. /**
  54292. * Diffuse Texture used in the material.
  54293. * Should be author in a specific way for the best result (refer to the documentation).
  54294. */
  54295. diffuseTexture: Nullable<BaseTexture>;
  54296. protected _shadowLights: Nullable<IShadowLight[]>;
  54297. /**
  54298. * Specify the list of lights casting shadow on the material.
  54299. * All scene shadow lights will be included if null.
  54300. */
  54301. shadowLights: Nullable<IShadowLight[]>;
  54302. protected _shadowLevel: float;
  54303. /**
  54304. * Helps adjusting the shadow to a softer level if required.
  54305. * 0 means black shadows and 1 means no shadows.
  54306. */
  54307. shadowLevel: float;
  54308. protected _sceneCenter: Vector3;
  54309. /**
  54310. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54311. * It is usually zero but might be interesting to modify according to your setup.
  54312. */
  54313. sceneCenter: Vector3;
  54314. protected _opacityFresnel: boolean;
  54315. /**
  54316. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54317. * This helps ensuring a nice transition when the camera goes under the ground.
  54318. */
  54319. opacityFresnel: boolean;
  54320. protected _reflectionFresnel: boolean;
  54321. /**
  54322. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54323. * This helps adding a mirror texture on the ground.
  54324. */
  54325. reflectionFresnel: boolean;
  54326. protected _reflectionFalloffDistance: number;
  54327. /**
  54328. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54329. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54330. */
  54331. reflectionFalloffDistance: number;
  54332. protected _reflectionAmount: number;
  54333. /**
  54334. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54335. */
  54336. reflectionAmount: number;
  54337. protected _reflectionReflectance0: number;
  54338. /**
  54339. * This specifies the weight of the reflection at grazing angle.
  54340. */
  54341. reflectionReflectance0: number;
  54342. protected _reflectionReflectance90: number;
  54343. /**
  54344. * This specifies the weight of the reflection at a perpendicular point of view.
  54345. */
  54346. reflectionReflectance90: number;
  54347. /**
  54348. * Sets the reflection reflectance fresnel values according to the default standard
  54349. * empirically know to work well :-)
  54350. */
  54351. set reflectionStandardFresnelWeight(value: number);
  54352. protected _useRGBColor: boolean;
  54353. /**
  54354. * Helps to directly use the maps channels instead of their level.
  54355. */
  54356. useRGBColor: boolean;
  54357. protected _enableNoise: boolean;
  54358. /**
  54359. * This helps reducing the banding effect that could occur on the background.
  54360. */
  54361. enableNoise: boolean;
  54362. /**
  54363. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54364. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54365. * Recommended to be keep at 1.0 except for special cases.
  54366. */
  54367. get fovMultiplier(): number;
  54368. set fovMultiplier(value: number);
  54369. private _fovMultiplier;
  54370. /**
  54371. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54372. */
  54373. useEquirectangularFOV: boolean;
  54374. private _maxSimultaneousLights;
  54375. /**
  54376. * Number of Simultaneous lights allowed on the material.
  54377. */
  54378. maxSimultaneousLights: int;
  54379. private _shadowOnly;
  54380. /**
  54381. * Make the material only render shadows
  54382. */
  54383. shadowOnly: boolean;
  54384. /**
  54385. * Default configuration related to image processing available in the Background Material.
  54386. */
  54387. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54388. /**
  54389. * Keep track of the image processing observer to allow dispose and replace.
  54390. */
  54391. private _imageProcessingObserver;
  54392. /**
  54393. * Attaches a new image processing configuration to the PBR Material.
  54394. * @param configuration (if null the scene configuration will be use)
  54395. */
  54396. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54397. /**
  54398. * Gets the image processing configuration used either in this material.
  54399. */
  54400. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54401. /**
  54402. * Sets the Default image processing configuration used either in the this material.
  54403. *
  54404. * If sets to null, the scene one is in use.
  54405. */
  54406. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54407. /**
  54408. * Gets wether the color curves effect is enabled.
  54409. */
  54410. get cameraColorCurvesEnabled(): boolean;
  54411. /**
  54412. * Sets wether the color curves effect is enabled.
  54413. */
  54414. set cameraColorCurvesEnabled(value: boolean);
  54415. /**
  54416. * Gets wether the color grading effect is enabled.
  54417. */
  54418. get cameraColorGradingEnabled(): boolean;
  54419. /**
  54420. * Gets wether the color grading effect is enabled.
  54421. */
  54422. set cameraColorGradingEnabled(value: boolean);
  54423. /**
  54424. * Gets wether tonemapping is enabled or not.
  54425. */
  54426. get cameraToneMappingEnabled(): boolean;
  54427. /**
  54428. * Sets wether tonemapping is enabled or not
  54429. */
  54430. set cameraToneMappingEnabled(value: boolean);
  54431. /**
  54432. * The camera exposure used on this material.
  54433. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54434. * This corresponds to a photographic exposure.
  54435. */
  54436. get cameraExposure(): float;
  54437. /**
  54438. * The camera exposure used on this material.
  54439. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54440. * This corresponds to a photographic exposure.
  54441. */
  54442. set cameraExposure(value: float);
  54443. /**
  54444. * Gets The camera contrast used on this material.
  54445. */
  54446. get cameraContrast(): float;
  54447. /**
  54448. * Sets The camera contrast used on this material.
  54449. */
  54450. set cameraContrast(value: float);
  54451. /**
  54452. * Gets the Color Grading 2D Lookup Texture.
  54453. */
  54454. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54455. /**
  54456. * Sets the Color Grading 2D Lookup Texture.
  54457. */
  54458. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54459. /**
  54460. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54461. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54462. * 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;
  54463. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54464. */
  54465. get cameraColorCurves(): Nullable<ColorCurves>;
  54466. /**
  54467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54469. * 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;
  54470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54471. */
  54472. set cameraColorCurves(value: Nullable<ColorCurves>);
  54473. /**
  54474. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54475. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54476. */
  54477. switchToBGR: boolean;
  54478. private _renderTargets;
  54479. private _reflectionControls;
  54480. private _white;
  54481. private _primaryShadowColor;
  54482. private _primaryHighlightColor;
  54483. /**
  54484. * Instantiates a Background Material in the given scene
  54485. * @param name The friendly name of the material
  54486. * @param scene The scene to add the material to
  54487. */
  54488. constructor(name: string, scene: Scene);
  54489. /**
  54490. * Gets a boolean indicating that current material needs to register RTT
  54491. */
  54492. get hasRenderTargetTextures(): boolean;
  54493. /**
  54494. * The entire material has been created in order to prevent overdraw.
  54495. * @returns false
  54496. */
  54497. needAlphaTesting(): boolean;
  54498. /**
  54499. * The entire material has been created in order to prevent overdraw.
  54500. * @returns true if blending is enable
  54501. */
  54502. needAlphaBlending(): boolean;
  54503. /**
  54504. * Checks wether the material is ready to be rendered for a given mesh.
  54505. * @param mesh The mesh to render
  54506. * @param subMesh The submesh to check against
  54507. * @param useInstances Specify wether or not the material is used with instances
  54508. * @returns true if all the dependencies are ready (Textures, Effects...)
  54509. */
  54510. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54511. /**
  54512. * Compute the primary color according to the chosen perceptual color.
  54513. */
  54514. private _computePrimaryColorFromPerceptualColor;
  54515. /**
  54516. * Compute the highlights and shadow colors according to their chosen levels.
  54517. */
  54518. private _computePrimaryColors;
  54519. /**
  54520. * Build the uniform buffer used in the material.
  54521. */
  54522. buildUniformLayout(): void;
  54523. /**
  54524. * Unbind the material.
  54525. */
  54526. unbind(): void;
  54527. /**
  54528. * Bind only the world matrix to the material.
  54529. * @param world The world matrix to bind.
  54530. */
  54531. bindOnlyWorldMatrix(world: Matrix): void;
  54532. /**
  54533. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54534. * @param world The world matrix to bind.
  54535. * @param subMesh The submesh to bind for.
  54536. */
  54537. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54538. /**
  54539. * Checks to see if a texture is used in the material.
  54540. * @param texture - Base texture to use.
  54541. * @returns - Boolean specifying if a texture is used in the material.
  54542. */
  54543. hasTexture(texture: BaseTexture): boolean;
  54544. /**
  54545. * Dispose the material.
  54546. * @param forceDisposeEffect Force disposal of the associated effect.
  54547. * @param forceDisposeTextures Force disposal of the associated textures.
  54548. */
  54549. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54550. /**
  54551. * Clones the material.
  54552. * @param name The cloned name.
  54553. * @returns The cloned material.
  54554. */
  54555. clone(name: string): BackgroundMaterial;
  54556. /**
  54557. * Serializes the current material to its JSON representation.
  54558. * @returns The JSON representation.
  54559. */
  54560. serialize(): any;
  54561. /**
  54562. * Gets the class name of the material
  54563. * @returns "BackgroundMaterial"
  54564. */
  54565. getClassName(): string;
  54566. /**
  54567. * Parse a JSON input to create back a background material.
  54568. * @param source The JSON data to parse
  54569. * @param scene The scene to create the parsed material in
  54570. * @param rootUrl The root url of the assets the material depends upon
  54571. * @returns the instantiated BackgroundMaterial.
  54572. */
  54573. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54574. }
  54575. }
  54576. declare module BABYLON {
  54577. /**
  54578. * Represents the different options available during the creation of
  54579. * a Environment helper.
  54580. *
  54581. * This can control the default ground, skybox and image processing setup of your scene.
  54582. */
  54583. export interface IEnvironmentHelperOptions {
  54584. /**
  54585. * Specifies whether or not to create a ground.
  54586. * True by default.
  54587. */
  54588. createGround: boolean;
  54589. /**
  54590. * Specifies the ground size.
  54591. * 15 by default.
  54592. */
  54593. groundSize: number;
  54594. /**
  54595. * The texture used on the ground for the main color.
  54596. * Comes from the BabylonJS CDN by default.
  54597. *
  54598. * Remarks: Can be either a texture or a url.
  54599. */
  54600. groundTexture: string | BaseTexture;
  54601. /**
  54602. * The color mixed in the ground texture by default.
  54603. * BabylonJS clearColor by default.
  54604. */
  54605. groundColor: Color3;
  54606. /**
  54607. * Specifies the ground opacity.
  54608. * 1 by default.
  54609. */
  54610. groundOpacity: number;
  54611. /**
  54612. * Enables the ground to receive shadows.
  54613. * True by default.
  54614. */
  54615. enableGroundShadow: boolean;
  54616. /**
  54617. * Helps preventing the shadow to be fully black on the ground.
  54618. * 0.5 by default.
  54619. */
  54620. groundShadowLevel: number;
  54621. /**
  54622. * Creates a mirror texture attach to the ground.
  54623. * false by default.
  54624. */
  54625. enableGroundMirror: boolean;
  54626. /**
  54627. * Specifies the ground mirror size ratio.
  54628. * 0.3 by default as the default kernel is 64.
  54629. */
  54630. groundMirrorSizeRatio: number;
  54631. /**
  54632. * Specifies the ground mirror blur kernel size.
  54633. * 64 by default.
  54634. */
  54635. groundMirrorBlurKernel: number;
  54636. /**
  54637. * Specifies the ground mirror visibility amount.
  54638. * 1 by default
  54639. */
  54640. groundMirrorAmount: number;
  54641. /**
  54642. * Specifies the ground mirror reflectance weight.
  54643. * This uses the standard weight of the background material to setup the fresnel effect
  54644. * of the mirror.
  54645. * 1 by default.
  54646. */
  54647. groundMirrorFresnelWeight: number;
  54648. /**
  54649. * Specifies the ground mirror Falloff distance.
  54650. * This can helps reducing the size of the reflection.
  54651. * 0 by Default.
  54652. */
  54653. groundMirrorFallOffDistance: number;
  54654. /**
  54655. * Specifies the ground mirror texture type.
  54656. * Unsigned Int by Default.
  54657. */
  54658. groundMirrorTextureType: number;
  54659. /**
  54660. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54661. * the shown objects.
  54662. */
  54663. groundYBias: number;
  54664. /**
  54665. * Specifies whether or not to create a skybox.
  54666. * True by default.
  54667. */
  54668. createSkybox: boolean;
  54669. /**
  54670. * Specifies the skybox size.
  54671. * 20 by default.
  54672. */
  54673. skyboxSize: number;
  54674. /**
  54675. * The texture used on the skybox for the main color.
  54676. * Comes from the BabylonJS CDN by default.
  54677. *
  54678. * Remarks: Can be either a texture or a url.
  54679. */
  54680. skyboxTexture: string | BaseTexture;
  54681. /**
  54682. * The color mixed in the skybox texture by default.
  54683. * BabylonJS clearColor by default.
  54684. */
  54685. skyboxColor: Color3;
  54686. /**
  54687. * The background rotation around the Y axis of the scene.
  54688. * This helps aligning the key lights of your scene with the background.
  54689. * 0 by default.
  54690. */
  54691. backgroundYRotation: number;
  54692. /**
  54693. * Compute automatically the size of the elements to best fit with the scene.
  54694. */
  54695. sizeAuto: boolean;
  54696. /**
  54697. * Default position of the rootMesh if autoSize is not true.
  54698. */
  54699. rootPosition: Vector3;
  54700. /**
  54701. * Sets up the image processing in the scene.
  54702. * true by default.
  54703. */
  54704. setupImageProcessing: boolean;
  54705. /**
  54706. * The texture used as your environment texture in the scene.
  54707. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54708. *
  54709. * Remarks: Can be either a texture or a url.
  54710. */
  54711. environmentTexture: string | BaseTexture;
  54712. /**
  54713. * The value of the exposure to apply to the scene.
  54714. * 0.6 by default if setupImageProcessing is true.
  54715. */
  54716. cameraExposure: number;
  54717. /**
  54718. * The value of the contrast to apply to the scene.
  54719. * 1.6 by default if setupImageProcessing is true.
  54720. */
  54721. cameraContrast: number;
  54722. /**
  54723. * Specifies whether or not tonemapping should be enabled in the scene.
  54724. * true by default if setupImageProcessing is true.
  54725. */
  54726. toneMappingEnabled: boolean;
  54727. }
  54728. /**
  54729. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54730. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54731. * It also helps with the default setup of your imageProcessing configuration.
  54732. */
  54733. export class EnvironmentHelper {
  54734. /**
  54735. * Default ground texture URL.
  54736. */
  54737. private static _groundTextureCDNUrl;
  54738. /**
  54739. * Default skybox texture URL.
  54740. */
  54741. private static _skyboxTextureCDNUrl;
  54742. /**
  54743. * Default environment texture URL.
  54744. */
  54745. private static _environmentTextureCDNUrl;
  54746. /**
  54747. * Creates the default options for the helper.
  54748. */
  54749. private static _getDefaultOptions;
  54750. private _rootMesh;
  54751. /**
  54752. * Gets the root mesh created by the helper.
  54753. */
  54754. get rootMesh(): Mesh;
  54755. private _skybox;
  54756. /**
  54757. * Gets the skybox created by the helper.
  54758. */
  54759. get skybox(): Nullable<Mesh>;
  54760. private _skyboxTexture;
  54761. /**
  54762. * Gets the skybox texture created by the helper.
  54763. */
  54764. get skyboxTexture(): Nullable<BaseTexture>;
  54765. private _skyboxMaterial;
  54766. /**
  54767. * Gets the skybox material created by the helper.
  54768. */
  54769. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54770. private _ground;
  54771. /**
  54772. * Gets the ground mesh created by the helper.
  54773. */
  54774. get ground(): Nullable<Mesh>;
  54775. private _groundTexture;
  54776. /**
  54777. * Gets the ground texture created by the helper.
  54778. */
  54779. get groundTexture(): Nullable<BaseTexture>;
  54780. private _groundMirror;
  54781. /**
  54782. * Gets the ground mirror created by the helper.
  54783. */
  54784. get groundMirror(): Nullable<MirrorTexture>;
  54785. /**
  54786. * Gets the ground mirror render list to helps pushing the meshes
  54787. * you wish in the ground reflection.
  54788. */
  54789. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54790. private _groundMaterial;
  54791. /**
  54792. * Gets the ground material created by the helper.
  54793. */
  54794. get groundMaterial(): Nullable<BackgroundMaterial>;
  54795. /**
  54796. * Stores the creation options.
  54797. */
  54798. private readonly _scene;
  54799. private _options;
  54800. /**
  54801. * This observable will be notified with any error during the creation of the environment,
  54802. * mainly texture creation errors.
  54803. */
  54804. onErrorObservable: Observable<{
  54805. message?: string;
  54806. exception?: any;
  54807. }>;
  54808. /**
  54809. * constructor
  54810. * @param options Defines the options we want to customize the helper
  54811. * @param scene The scene to add the material to
  54812. */
  54813. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54814. /**
  54815. * Updates the background according to the new options
  54816. * @param options
  54817. */
  54818. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54819. /**
  54820. * Sets the primary color of all the available elements.
  54821. * @param color the main color to affect to the ground and the background
  54822. */
  54823. setMainColor(color: Color3): void;
  54824. /**
  54825. * Setup the image processing according to the specified options.
  54826. */
  54827. private _setupImageProcessing;
  54828. /**
  54829. * Setup the environment texture according to the specified options.
  54830. */
  54831. private _setupEnvironmentTexture;
  54832. /**
  54833. * Setup the background according to the specified options.
  54834. */
  54835. private _setupBackground;
  54836. /**
  54837. * Get the scene sizes according to the setup.
  54838. */
  54839. private _getSceneSize;
  54840. /**
  54841. * Setup the ground according to the specified options.
  54842. */
  54843. private _setupGround;
  54844. /**
  54845. * Setup the ground material according to the specified options.
  54846. */
  54847. private _setupGroundMaterial;
  54848. /**
  54849. * Setup the ground diffuse texture according to the specified options.
  54850. */
  54851. private _setupGroundDiffuseTexture;
  54852. /**
  54853. * Setup the ground mirror texture according to the specified options.
  54854. */
  54855. private _setupGroundMirrorTexture;
  54856. /**
  54857. * Setup the ground to receive the mirror texture.
  54858. */
  54859. private _setupMirrorInGroundMaterial;
  54860. /**
  54861. * Setup the skybox according to the specified options.
  54862. */
  54863. private _setupSkybox;
  54864. /**
  54865. * Setup the skybox material according to the specified options.
  54866. */
  54867. private _setupSkyboxMaterial;
  54868. /**
  54869. * Setup the skybox reflection texture according to the specified options.
  54870. */
  54871. private _setupSkyboxReflectionTexture;
  54872. private _errorHandler;
  54873. /**
  54874. * Dispose all the elements created by the Helper.
  54875. */
  54876. dispose(): void;
  54877. }
  54878. }
  54879. declare module BABYLON {
  54880. /**
  54881. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54882. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54883. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54884. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54885. */
  54886. export class PhotoDome extends TransformNode {
  54887. /**
  54888. * Define the image as a Monoscopic panoramic 360 image.
  54889. */
  54890. static readonly MODE_MONOSCOPIC: number;
  54891. /**
  54892. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54893. */
  54894. static readonly MODE_TOPBOTTOM: number;
  54895. /**
  54896. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54897. */
  54898. static readonly MODE_SIDEBYSIDE: number;
  54899. private _useDirectMapping;
  54900. /**
  54901. * The texture being displayed on the sphere
  54902. */
  54903. protected _photoTexture: Texture;
  54904. /**
  54905. * Gets or sets the texture being displayed on the sphere
  54906. */
  54907. get photoTexture(): Texture;
  54908. set photoTexture(value: Texture);
  54909. /**
  54910. * Observable raised when an error occured while loading the 360 image
  54911. */
  54912. onLoadErrorObservable: Observable<string>;
  54913. /**
  54914. * The skybox material
  54915. */
  54916. protected _material: BackgroundMaterial;
  54917. /**
  54918. * The surface used for the skybox
  54919. */
  54920. protected _mesh: Mesh;
  54921. /**
  54922. * Gets the mesh used for the skybox.
  54923. */
  54924. get mesh(): Mesh;
  54925. /**
  54926. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54927. * Also see the options.resolution property.
  54928. */
  54929. get fovMultiplier(): number;
  54930. set fovMultiplier(value: number);
  54931. private _imageMode;
  54932. /**
  54933. * Gets or set the current video mode for the video. It can be:
  54934. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54935. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54936. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54937. */
  54938. get imageMode(): number;
  54939. set imageMode(value: number);
  54940. /**
  54941. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54942. * @param name Element's name, child elements will append suffixes for their own names.
  54943. * @param urlsOfPhoto defines the url of the photo to display
  54944. * @param options defines an object containing optional or exposed sub element properties
  54945. * @param onError defines a callback called when an error occured while loading the texture
  54946. */
  54947. constructor(name: string, urlOfPhoto: string, options: {
  54948. resolution?: number;
  54949. size?: number;
  54950. useDirectMapping?: boolean;
  54951. faceForward?: boolean;
  54952. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54953. private _onBeforeCameraRenderObserver;
  54954. private _changeImageMode;
  54955. /**
  54956. * Releases resources associated with this node.
  54957. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54958. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54959. */
  54960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54961. }
  54962. }
  54963. declare module BABYLON {
  54964. /**
  54965. * Class used to host RGBD texture specific utilities
  54966. */
  54967. export class RGBDTextureTools {
  54968. /**
  54969. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54970. * @param texture the texture to expand.
  54971. */
  54972. static ExpandRGBDTexture(texture: Texture): void;
  54973. }
  54974. }
  54975. declare module BABYLON {
  54976. /**
  54977. * Class used to host texture specific utilities
  54978. */
  54979. export class BRDFTextureTools {
  54980. /**
  54981. * Prevents texture cache collision
  54982. */
  54983. private static _instanceNumber;
  54984. /**
  54985. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54986. * @param scene defines the hosting scene
  54987. * @returns the environment BRDF texture
  54988. */
  54989. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54990. private static _environmentBRDFBase64Texture;
  54991. }
  54992. }
  54993. declare module BABYLON {
  54994. /**
  54995. * @hidden
  54996. */
  54997. export interface IMaterialClearCoatDefines {
  54998. CLEARCOAT: boolean;
  54999. CLEARCOAT_DEFAULTIOR: boolean;
  55000. CLEARCOAT_TEXTURE: boolean;
  55001. CLEARCOAT_TEXTUREDIRECTUV: number;
  55002. CLEARCOAT_BUMP: boolean;
  55003. CLEARCOAT_BUMPDIRECTUV: number;
  55004. CLEARCOAT_TINT: boolean;
  55005. CLEARCOAT_TINT_TEXTURE: boolean;
  55006. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55007. /** @hidden */
  55008. _areTexturesDirty: boolean;
  55009. }
  55010. /**
  55011. * Define the code related to the clear coat parameters of the pbr material.
  55012. */
  55013. export class PBRClearCoatConfiguration {
  55014. /**
  55015. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55016. * The default fits with a polyurethane material.
  55017. */
  55018. private static readonly _DefaultIndexOfRefraction;
  55019. private _isEnabled;
  55020. /**
  55021. * Defines if the clear coat is enabled in the material.
  55022. */
  55023. isEnabled: boolean;
  55024. /**
  55025. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55026. */
  55027. intensity: number;
  55028. /**
  55029. * Defines the clear coat layer roughness.
  55030. */
  55031. roughness: number;
  55032. private _indexOfRefraction;
  55033. /**
  55034. * Defines the index of refraction of the clear coat.
  55035. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55036. * The default fits with a polyurethane material.
  55037. * Changing the default value is more performance intensive.
  55038. */
  55039. indexOfRefraction: number;
  55040. private _texture;
  55041. /**
  55042. * Stores the clear coat values in a texture.
  55043. */
  55044. texture: Nullable<BaseTexture>;
  55045. private _bumpTexture;
  55046. /**
  55047. * Define the clear coat specific bump texture.
  55048. */
  55049. bumpTexture: Nullable<BaseTexture>;
  55050. private _isTintEnabled;
  55051. /**
  55052. * Defines if the clear coat tint is enabled in the material.
  55053. */
  55054. isTintEnabled: boolean;
  55055. /**
  55056. * Defines the clear coat tint of the material.
  55057. * This is only use if tint is enabled
  55058. */
  55059. tintColor: Color3;
  55060. /**
  55061. * Defines the distance at which the tint color should be found in the
  55062. * clear coat media.
  55063. * This is only use if tint is enabled
  55064. */
  55065. tintColorAtDistance: number;
  55066. /**
  55067. * Defines the clear coat layer thickness.
  55068. * This is only use if tint is enabled
  55069. */
  55070. tintThickness: number;
  55071. private _tintTexture;
  55072. /**
  55073. * Stores the clear tint values in a texture.
  55074. * rgb is tint
  55075. * a is a thickness factor
  55076. */
  55077. tintTexture: Nullable<BaseTexture>;
  55078. /** @hidden */
  55079. private _internalMarkAllSubMeshesAsTexturesDirty;
  55080. /** @hidden */
  55081. _markAllSubMeshesAsTexturesDirty(): void;
  55082. /**
  55083. * Instantiate a new istance of clear coat configuration.
  55084. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55085. */
  55086. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55087. /**
  55088. * Gets wehter the submesh is ready to be used or not.
  55089. * @param defines the list of "defines" to update.
  55090. * @param scene defines the scene the material belongs to.
  55091. * @param engine defines the engine the material belongs to.
  55092. * @param disableBumpMap defines wether the material disables bump or not.
  55093. * @returns - boolean indicating that the submesh is ready or not.
  55094. */
  55095. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55096. /**
  55097. * Checks to see if a texture is used in the material.
  55098. * @param defines the list of "defines" to update.
  55099. * @param scene defines the scene to the material belongs to.
  55100. */
  55101. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55102. /**
  55103. * Binds the material data.
  55104. * @param uniformBuffer defines the Uniform buffer to fill in.
  55105. * @param scene defines the scene the material belongs to.
  55106. * @param engine defines the engine the material belongs to.
  55107. * @param disableBumpMap defines wether the material disables bump or not.
  55108. * @param isFrozen defines wether the material is frozen or not.
  55109. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55110. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55111. */
  55112. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55113. /**
  55114. * Checks to see if a texture is used in the material.
  55115. * @param texture - Base texture to use.
  55116. * @returns - Boolean specifying if a texture is used in the material.
  55117. */
  55118. hasTexture(texture: BaseTexture): boolean;
  55119. /**
  55120. * Returns an array of the actively used textures.
  55121. * @param activeTextures Array of BaseTextures
  55122. */
  55123. getActiveTextures(activeTextures: BaseTexture[]): void;
  55124. /**
  55125. * Returns the animatable textures.
  55126. * @param animatables Array of animatable textures.
  55127. */
  55128. getAnimatables(animatables: IAnimatable[]): void;
  55129. /**
  55130. * Disposes the resources of the material.
  55131. * @param forceDisposeTextures - Forces the disposal of all textures.
  55132. */
  55133. dispose(forceDisposeTextures?: boolean): void;
  55134. /**
  55135. * Get the current class name of the texture useful for serialization or dynamic coding.
  55136. * @returns "PBRClearCoatConfiguration"
  55137. */
  55138. getClassName(): string;
  55139. /**
  55140. * Add fallbacks to the effect fallbacks list.
  55141. * @param defines defines the Base texture to use.
  55142. * @param fallbacks defines the current fallback list.
  55143. * @param currentRank defines the current fallback rank.
  55144. * @returns the new fallback rank.
  55145. */
  55146. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55147. /**
  55148. * Add the required uniforms to the current list.
  55149. * @param uniforms defines the current uniform list.
  55150. */
  55151. static AddUniforms(uniforms: string[]): void;
  55152. /**
  55153. * Add the required samplers to the current list.
  55154. * @param samplers defines the current sampler list.
  55155. */
  55156. static AddSamplers(samplers: string[]): void;
  55157. /**
  55158. * Add the required uniforms to the current buffer.
  55159. * @param uniformBuffer defines the current uniform buffer.
  55160. */
  55161. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55162. /**
  55163. * Makes a duplicate of the current configuration into another one.
  55164. * @param clearCoatConfiguration define the config where to copy the info
  55165. */
  55166. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55167. /**
  55168. * Serializes this clear coat configuration.
  55169. * @returns - An object with the serialized config.
  55170. */
  55171. serialize(): any;
  55172. /**
  55173. * Parses a anisotropy Configuration from a serialized object.
  55174. * @param source - Serialized object.
  55175. * @param scene Defines the scene we are parsing for
  55176. * @param rootUrl Defines the rootUrl to load from
  55177. */
  55178. parse(source: any, scene: Scene, rootUrl: string): void;
  55179. }
  55180. }
  55181. declare module BABYLON {
  55182. /**
  55183. * @hidden
  55184. */
  55185. export interface IMaterialAnisotropicDefines {
  55186. ANISOTROPIC: boolean;
  55187. ANISOTROPIC_TEXTURE: boolean;
  55188. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55189. MAINUV1: boolean;
  55190. _areTexturesDirty: boolean;
  55191. _needUVs: boolean;
  55192. }
  55193. /**
  55194. * Define the code related to the anisotropic parameters of the pbr material.
  55195. */
  55196. export class PBRAnisotropicConfiguration {
  55197. private _isEnabled;
  55198. /**
  55199. * Defines if the anisotropy is enabled in the material.
  55200. */
  55201. isEnabled: boolean;
  55202. /**
  55203. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55204. */
  55205. intensity: number;
  55206. /**
  55207. * Defines if the effect is along the tangents, bitangents or in between.
  55208. * By default, the effect is "strectching" the highlights along the tangents.
  55209. */
  55210. direction: Vector2;
  55211. private _texture;
  55212. /**
  55213. * Stores the anisotropy values in a texture.
  55214. * rg is direction (like normal from -1 to 1)
  55215. * b is a intensity
  55216. */
  55217. texture: Nullable<BaseTexture>;
  55218. /** @hidden */
  55219. private _internalMarkAllSubMeshesAsTexturesDirty;
  55220. /** @hidden */
  55221. _markAllSubMeshesAsTexturesDirty(): void;
  55222. /**
  55223. * Instantiate a new istance of anisotropy configuration.
  55224. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55225. */
  55226. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55227. /**
  55228. * Specifies that the submesh is ready to be used.
  55229. * @param defines the list of "defines" to update.
  55230. * @param scene defines the scene the material belongs to.
  55231. * @returns - boolean indicating that the submesh is ready or not.
  55232. */
  55233. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55234. /**
  55235. * Checks to see if a texture is used in the material.
  55236. * @param defines the list of "defines" to update.
  55237. * @param mesh the mesh we are preparing the defines for.
  55238. * @param scene defines the scene the material belongs to.
  55239. */
  55240. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55241. /**
  55242. * Binds the material data.
  55243. * @param uniformBuffer defines the Uniform buffer to fill in.
  55244. * @param scene defines the scene the material belongs to.
  55245. * @param isFrozen defines wether the material is frozen or not.
  55246. */
  55247. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55248. /**
  55249. * Checks to see if a texture is used in the material.
  55250. * @param texture - Base texture to use.
  55251. * @returns - Boolean specifying if a texture is used in the material.
  55252. */
  55253. hasTexture(texture: BaseTexture): boolean;
  55254. /**
  55255. * Returns an array of the actively used textures.
  55256. * @param activeTextures Array of BaseTextures
  55257. */
  55258. getActiveTextures(activeTextures: BaseTexture[]): void;
  55259. /**
  55260. * Returns the animatable textures.
  55261. * @param animatables Array of animatable textures.
  55262. */
  55263. getAnimatables(animatables: IAnimatable[]): void;
  55264. /**
  55265. * Disposes the resources of the material.
  55266. * @param forceDisposeTextures - Forces the disposal of all textures.
  55267. */
  55268. dispose(forceDisposeTextures?: boolean): void;
  55269. /**
  55270. * Get the current class name of the texture useful for serialization or dynamic coding.
  55271. * @returns "PBRAnisotropicConfiguration"
  55272. */
  55273. getClassName(): string;
  55274. /**
  55275. * Add fallbacks to the effect fallbacks list.
  55276. * @param defines defines the Base texture to use.
  55277. * @param fallbacks defines the current fallback list.
  55278. * @param currentRank defines the current fallback rank.
  55279. * @returns the new fallback rank.
  55280. */
  55281. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55282. /**
  55283. * Add the required uniforms to the current list.
  55284. * @param uniforms defines the current uniform list.
  55285. */
  55286. static AddUniforms(uniforms: string[]): void;
  55287. /**
  55288. * Add the required uniforms to the current buffer.
  55289. * @param uniformBuffer defines the current uniform buffer.
  55290. */
  55291. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55292. /**
  55293. * Add the required samplers to the current list.
  55294. * @param samplers defines the current sampler list.
  55295. */
  55296. static AddSamplers(samplers: string[]): void;
  55297. /**
  55298. * Makes a duplicate of the current configuration into another one.
  55299. * @param anisotropicConfiguration define the config where to copy the info
  55300. */
  55301. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55302. /**
  55303. * Serializes this anisotropy configuration.
  55304. * @returns - An object with the serialized config.
  55305. */
  55306. serialize(): any;
  55307. /**
  55308. * Parses a anisotropy Configuration from a serialized object.
  55309. * @param source - Serialized object.
  55310. * @param scene Defines the scene we are parsing for
  55311. * @param rootUrl Defines the rootUrl to load from
  55312. */
  55313. parse(source: any, scene: Scene, rootUrl: string): void;
  55314. }
  55315. }
  55316. declare module BABYLON {
  55317. /**
  55318. * @hidden
  55319. */
  55320. export interface IMaterialBRDFDefines {
  55321. BRDF_V_HEIGHT_CORRELATED: boolean;
  55322. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55323. SPHERICAL_HARMONICS: boolean;
  55324. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55325. /** @hidden */
  55326. _areMiscDirty: boolean;
  55327. }
  55328. /**
  55329. * Define the code related to the BRDF parameters of the pbr material.
  55330. */
  55331. export class PBRBRDFConfiguration {
  55332. /**
  55333. * Default value used for the energy conservation.
  55334. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55335. */
  55336. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55337. /**
  55338. * Default value used for the Smith Visibility Height Correlated mode.
  55339. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55340. */
  55341. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55342. /**
  55343. * Default value used for the IBL diffuse part.
  55344. * This can help switching back to the polynomials mode globally which is a tiny bit
  55345. * less GPU intensive at the drawback of a lower quality.
  55346. */
  55347. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55348. /**
  55349. * Default value used for activating energy conservation for the specular workflow.
  55350. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55351. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55352. */
  55353. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55354. private _useEnergyConservation;
  55355. /**
  55356. * Defines if the material uses energy conservation.
  55357. */
  55358. useEnergyConservation: boolean;
  55359. private _useSmithVisibilityHeightCorrelated;
  55360. /**
  55361. * LEGACY Mode set to false
  55362. * Defines if the material uses height smith correlated visibility term.
  55363. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55364. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55365. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55366. * Not relying on height correlated will also disable energy conservation.
  55367. */
  55368. useSmithVisibilityHeightCorrelated: boolean;
  55369. private _useSphericalHarmonics;
  55370. /**
  55371. * LEGACY Mode set to false
  55372. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55373. * diffuse part of the IBL.
  55374. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55375. * to the ground truth.
  55376. */
  55377. useSphericalHarmonics: boolean;
  55378. private _useSpecularGlossinessInputEnergyConservation;
  55379. /**
  55380. * Defines if the material uses energy conservation, when the specular workflow is active.
  55381. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55382. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55383. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55384. */
  55385. useSpecularGlossinessInputEnergyConservation: boolean;
  55386. /** @hidden */
  55387. private _internalMarkAllSubMeshesAsMiscDirty;
  55388. /** @hidden */
  55389. _markAllSubMeshesAsMiscDirty(): void;
  55390. /**
  55391. * Instantiate a new istance of clear coat configuration.
  55392. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55393. */
  55394. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55395. /**
  55396. * Checks to see if a texture is used in the material.
  55397. * @param defines the list of "defines" to update.
  55398. */
  55399. prepareDefines(defines: IMaterialBRDFDefines): void;
  55400. /**
  55401. * Get the current class name of the texture useful for serialization or dynamic coding.
  55402. * @returns "PBRClearCoatConfiguration"
  55403. */
  55404. getClassName(): string;
  55405. /**
  55406. * Makes a duplicate of the current configuration into another one.
  55407. * @param brdfConfiguration define the config where to copy the info
  55408. */
  55409. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55410. /**
  55411. * Serializes this BRDF configuration.
  55412. * @returns - An object with the serialized config.
  55413. */
  55414. serialize(): any;
  55415. /**
  55416. * Parses a anisotropy Configuration from a serialized object.
  55417. * @param source - Serialized object.
  55418. * @param scene Defines the scene we are parsing for
  55419. * @param rootUrl Defines the rootUrl to load from
  55420. */
  55421. parse(source: any, scene: Scene, rootUrl: string): void;
  55422. }
  55423. }
  55424. declare module BABYLON {
  55425. /**
  55426. * @hidden
  55427. */
  55428. export interface IMaterialSheenDefines {
  55429. SHEEN: boolean;
  55430. SHEEN_TEXTURE: boolean;
  55431. SHEEN_TEXTUREDIRECTUV: number;
  55432. SHEEN_LINKWITHALBEDO: boolean;
  55433. SHEEN_ROUGHNESS: boolean;
  55434. SHEEN_ALBEDOSCALING: boolean;
  55435. /** @hidden */
  55436. _areTexturesDirty: boolean;
  55437. }
  55438. /**
  55439. * Define the code related to the Sheen parameters of the pbr material.
  55440. */
  55441. export class PBRSheenConfiguration {
  55442. private _isEnabled;
  55443. /**
  55444. * Defines if the material uses sheen.
  55445. */
  55446. isEnabled: boolean;
  55447. private _linkSheenWithAlbedo;
  55448. /**
  55449. * Defines if the sheen is linked to the sheen color.
  55450. */
  55451. linkSheenWithAlbedo: boolean;
  55452. /**
  55453. * Defines the sheen intensity.
  55454. */
  55455. intensity: number;
  55456. /**
  55457. * Defines the sheen color.
  55458. */
  55459. color: Color3;
  55460. private _texture;
  55461. /**
  55462. * Stores the sheen tint values in a texture.
  55463. * rgb is tint
  55464. * a is a intensity or roughness if roughness has been defined
  55465. */
  55466. texture: Nullable<BaseTexture>;
  55467. private _roughness;
  55468. /**
  55469. * Defines the sheen roughness.
  55470. * It is not taken into account if linkSheenWithAlbedo is true.
  55471. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55472. */
  55473. roughness: Nullable<number>;
  55474. private _albedoScaling;
  55475. /**
  55476. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55477. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55478. * making it easier to setup and tweak the effect
  55479. */
  55480. albedoScaling: boolean;
  55481. /** @hidden */
  55482. private _internalMarkAllSubMeshesAsTexturesDirty;
  55483. /** @hidden */
  55484. _markAllSubMeshesAsTexturesDirty(): void;
  55485. /**
  55486. * Instantiate a new istance of clear coat configuration.
  55487. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55488. */
  55489. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55490. /**
  55491. * Specifies that the submesh is ready to be used.
  55492. * @param defines the list of "defines" to update.
  55493. * @param scene defines the scene the material belongs to.
  55494. * @returns - boolean indicating that the submesh is ready or not.
  55495. */
  55496. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55497. /**
  55498. * Checks to see if a texture is used in the material.
  55499. * @param defines the list of "defines" to update.
  55500. * @param scene defines the scene the material belongs to.
  55501. */
  55502. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55503. /**
  55504. * Binds the material data.
  55505. * @param uniformBuffer defines the Uniform buffer to fill in.
  55506. * @param scene defines the scene the material belongs to.
  55507. * @param isFrozen defines wether the material is frozen or not.
  55508. */
  55509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55510. /**
  55511. * Checks to see if a texture is used in the material.
  55512. * @param texture - Base texture to use.
  55513. * @returns - Boolean specifying if a texture is used in the material.
  55514. */
  55515. hasTexture(texture: BaseTexture): boolean;
  55516. /**
  55517. * Returns an array of the actively used textures.
  55518. * @param activeTextures Array of BaseTextures
  55519. */
  55520. getActiveTextures(activeTextures: BaseTexture[]): void;
  55521. /**
  55522. * Returns the animatable textures.
  55523. * @param animatables Array of animatable textures.
  55524. */
  55525. getAnimatables(animatables: IAnimatable[]): void;
  55526. /**
  55527. * Disposes the resources of the material.
  55528. * @param forceDisposeTextures - Forces the disposal of all textures.
  55529. */
  55530. dispose(forceDisposeTextures?: boolean): void;
  55531. /**
  55532. * Get the current class name of the texture useful for serialization or dynamic coding.
  55533. * @returns "PBRSheenConfiguration"
  55534. */
  55535. getClassName(): string;
  55536. /**
  55537. * Add fallbacks to the effect fallbacks list.
  55538. * @param defines defines the Base texture to use.
  55539. * @param fallbacks defines the current fallback list.
  55540. * @param currentRank defines the current fallback rank.
  55541. * @returns the new fallback rank.
  55542. */
  55543. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55544. /**
  55545. * Add the required uniforms to the current list.
  55546. * @param uniforms defines the current uniform list.
  55547. */
  55548. static AddUniforms(uniforms: string[]): void;
  55549. /**
  55550. * Add the required uniforms to the current buffer.
  55551. * @param uniformBuffer defines the current uniform buffer.
  55552. */
  55553. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55554. /**
  55555. * Add the required samplers to the current list.
  55556. * @param samplers defines the current sampler list.
  55557. */
  55558. static AddSamplers(samplers: string[]): void;
  55559. /**
  55560. * Makes a duplicate of the current configuration into another one.
  55561. * @param sheenConfiguration define the config where to copy the info
  55562. */
  55563. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55564. /**
  55565. * Serializes this BRDF configuration.
  55566. * @returns - An object with the serialized config.
  55567. */
  55568. serialize(): any;
  55569. /**
  55570. * Parses a anisotropy Configuration from a serialized object.
  55571. * @param source - Serialized object.
  55572. * @param scene Defines the scene we are parsing for
  55573. * @param rootUrl Defines the rootUrl to load from
  55574. */
  55575. parse(source: any, scene: Scene, rootUrl: string): void;
  55576. }
  55577. }
  55578. declare module BABYLON {
  55579. /**
  55580. * @hidden
  55581. */
  55582. export interface IMaterialSubSurfaceDefines {
  55583. SUBSURFACE: boolean;
  55584. SS_REFRACTION: boolean;
  55585. SS_TRANSLUCENCY: boolean;
  55586. SS_SCATTERING: boolean;
  55587. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55588. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55589. SS_REFRACTIONMAP_3D: boolean;
  55590. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55591. SS_LODINREFRACTIONALPHA: boolean;
  55592. SS_GAMMAREFRACTION: boolean;
  55593. SS_RGBDREFRACTION: boolean;
  55594. SS_LINEARSPECULARREFRACTION: boolean;
  55595. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55596. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55597. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55598. /** @hidden */
  55599. _areTexturesDirty: boolean;
  55600. }
  55601. /**
  55602. * Define the code related to the sub surface parameters of the pbr material.
  55603. */
  55604. export class PBRSubSurfaceConfiguration {
  55605. private _isRefractionEnabled;
  55606. /**
  55607. * Defines if the refraction is enabled in the material.
  55608. */
  55609. isRefractionEnabled: boolean;
  55610. private _isTranslucencyEnabled;
  55611. /**
  55612. * Defines if the translucency is enabled in the material.
  55613. */
  55614. isTranslucencyEnabled: boolean;
  55615. private _isScatteringEnabled;
  55616. /**
  55617. * Defines if the sub surface scattering is enabled in the material.
  55618. */
  55619. isScatteringEnabled: boolean;
  55620. private _scatteringDiffusionProfileIndex;
  55621. /**
  55622. * Diffusion profile for subsurface scattering.
  55623. * Useful for better scattering in the skins or foliages.
  55624. */
  55625. get scatteringDiffusionProfile(): Nullable<Color3>;
  55626. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55627. /**
  55628. * Defines the refraction intensity of the material.
  55629. * The refraction when enabled replaces the Diffuse part of the material.
  55630. * The intensity helps transitionning between diffuse and refraction.
  55631. */
  55632. refractionIntensity: number;
  55633. /**
  55634. * Defines the translucency intensity of the material.
  55635. * When translucency has been enabled, this defines how much of the "translucency"
  55636. * is addded to the diffuse part of the material.
  55637. */
  55638. translucencyIntensity: number;
  55639. /**
  55640. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55641. */
  55642. useAlbedoToTintRefraction: boolean;
  55643. private _thicknessTexture;
  55644. /**
  55645. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55646. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55647. * 0 would mean minimumThickness
  55648. * 1 would mean maximumThickness
  55649. * The other channels might be use as a mask to vary the different effects intensity.
  55650. */
  55651. thicknessTexture: Nullable<BaseTexture>;
  55652. private _refractionTexture;
  55653. /**
  55654. * Defines the texture to use for refraction.
  55655. */
  55656. refractionTexture: Nullable<BaseTexture>;
  55657. private _indexOfRefraction;
  55658. /**
  55659. * Index of refraction of the material base layer.
  55660. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55661. *
  55662. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55663. *
  55664. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55665. */
  55666. indexOfRefraction: number;
  55667. private _volumeIndexOfRefraction;
  55668. /**
  55669. * Index of refraction of the material's volume.
  55670. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55671. *
  55672. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55673. * the volume will use the same IOR as the surface.
  55674. */
  55675. get volumeIndexOfRefraction(): number;
  55676. set volumeIndexOfRefraction(value: number);
  55677. private _invertRefractionY;
  55678. /**
  55679. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55680. */
  55681. invertRefractionY: boolean;
  55682. private _linkRefractionWithTransparency;
  55683. /**
  55684. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55685. * Materials half opaque for instance using refraction could benefit from this control.
  55686. */
  55687. linkRefractionWithTransparency: boolean;
  55688. /**
  55689. * Defines the minimum thickness stored in the thickness map.
  55690. * If no thickness map is defined, this value will be used to simulate thickness.
  55691. */
  55692. minimumThickness: number;
  55693. /**
  55694. * Defines the maximum thickness stored in the thickness map.
  55695. */
  55696. maximumThickness: number;
  55697. /**
  55698. * Defines the volume tint of the material.
  55699. * This is used for both translucency and scattering.
  55700. */
  55701. tintColor: Color3;
  55702. /**
  55703. * Defines the distance at which the tint color should be found in the media.
  55704. * This is used for refraction only.
  55705. */
  55706. tintColorAtDistance: number;
  55707. /**
  55708. * Defines how far each channel transmit through the media.
  55709. * It is defined as a color to simplify it selection.
  55710. */
  55711. diffusionDistance: Color3;
  55712. private _useMaskFromThicknessTexture;
  55713. /**
  55714. * Stores the intensity of the different subsurface effects in the thickness texture.
  55715. * * the green channel is the translucency intensity.
  55716. * * the blue channel is the scattering intensity.
  55717. * * the alpha channel is the refraction intensity.
  55718. */
  55719. useMaskFromThicknessTexture: boolean;
  55720. private _scene;
  55721. /** @hidden */
  55722. private _internalMarkAllSubMeshesAsTexturesDirty;
  55723. private _internalMarkScenePrePassDirty;
  55724. /** @hidden */
  55725. _markAllSubMeshesAsTexturesDirty(): void;
  55726. /** @hidden */
  55727. _markScenePrePassDirty(): void;
  55728. /**
  55729. * Instantiate a new istance of sub surface configuration.
  55730. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55731. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55732. * @param scene The scene
  55733. */
  55734. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55735. /**
  55736. * Gets wehter the submesh is ready to be used or not.
  55737. * @param defines the list of "defines" to update.
  55738. * @param scene defines the scene the material belongs to.
  55739. * @returns - boolean indicating that the submesh is ready or not.
  55740. */
  55741. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55742. /**
  55743. * Checks to see if a texture is used in the material.
  55744. * @param defines the list of "defines" to update.
  55745. * @param scene defines the scene to the material belongs to.
  55746. */
  55747. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55748. /**
  55749. * Binds the material data.
  55750. * @param uniformBuffer defines the Uniform buffer to fill in.
  55751. * @param scene defines the scene the material belongs to.
  55752. * @param engine defines the engine the material belongs to.
  55753. * @param isFrozen defines whether the material is frozen or not.
  55754. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55755. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55756. */
  55757. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55758. /**
  55759. * Unbinds the material from the mesh.
  55760. * @param activeEffect defines the effect that should be unbound from.
  55761. * @returns true if unbound, otherwise false
  55762. */
  55763. unbind(activeEffect: Effect): boolean;
  55764. /**
  55765. * Returns the texture used for refraction or null if none is used.
  55766. * @param scene defines the scene the material belongs to.
  55767. * @returns - Refraction texture if present. If no refraction texture and refraction
  55768. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55769. */
  55770. private _getRefractionTexture;
  55771. /**
  55772. * Returns true if alpha blending should be disabled.
  55773. */
  55774. get disableAlphaBlending(): boolean;
  55775. /**
  55776. * Fills the list of render target textures.
  55777. * @param renderTargets the list of render targets to update
  55778. */
  55779. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55780. /**
  55781. * Checks to see if a texture is used in the material.
  55782. * @param texture - Base texture to use.
  55783. * @returns - Boolean specifying if a texture is used in the material.
  55784. */
  55785. hasTexture(texture: BaseTexture): boolean;
  55786. /**
  55787. * Gets a boolean indicating that current material needs to register RTT
  55788. * @returns true if this uses a render target otherwise false.
  55789. */
  55790. hasRenderTargetTextures(): boolean;
  55791. /**
  55792. * Returns an array of the actively used textures.
  55793. * @param activeTextures Array of BaseTextures
  55794. */
  55795. getActiveTextures(activeTextures: BaseTexture[]): void;
  55796. /**
  55797. * Returns the animatable textures.
  55798. * @param animatables Array of animatable textures.
  55799. */
  55800. getAnimatables(animatables: IAnimatable[]): void;
  55801. /**
  55802. * Disposes the resources of the material.
  55803. * @param forceDisposeTextures - Forces the disposal of all textures.
  55804. */
  55805. dispose(forceDisposeTextures?: boolean): void;
  55806. /**
  55807. * Get the current class name of the texture useful for serialization or dynamic coding.
  55808. * @returns "PBRSubSurfaceConfiguration"
  55809. */
  55810. getClassName(): string;
  55811. /**
  55812. * Add fallbacks to the effect fallbacks list.
  55813. * @param defines defines the Base texture to use.
  55814. * @param fallbacks defines the current fallback list.
  55815. * @param currentRank defines the current fallback rank.
  55816. * @returns the new fallback rank.
  55817. */
  55818. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55819. /**
  55820. * Add the required uniforms to the current list.
  55821. * @param uniforms defines the current uniform list.
  55822. */
  55823. static AddUniforms(uniforms: string[]): void;
  55824. /**
  55825. * Add the required samplers to the current list.
  55826. * @param samplers defines the current sampler list.
  55827. */
  55828. static AddSamplers(samplers: string[]): void;
  55829. /**
  55830. * Add the required uniforms to the current buffer.
  55831. * @param uniformBuffer defines the current uniform buffer.
  55832. */
  55833. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55834. /**
  55835. * Makes a duplicate of the current configuration into another one.
  55836. * @param configuration define the config where to copy the info
  55837. */
  55838. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55839. /**
  55840. * Serializes this Sub Surface configuration.
  55841. * @returns - An object with the serialized config.
  55842. */
  55843. serialize(): any;
  55844. /**
  55845. * Parses a anisotropy Configuration from a serialized object.
  55846. * @param source - Serialized object.
  55847. * @param scene Defines the scene we are parsing for
  55848. * @param rootUrl Defines the rootUrl to load from
  55849. */
  55850. parse(source: any, scene: Scene, rootUrl: string): void;
  55851. }
  55852. }
  55853. declare module BABYLON {
  55854. /** @hidden */
  55855. export var pbrFragmentDeclaration: {
  55856. name: string;
  55857. shader: string;
  55858. };
  55859. }
  55860. declare module BABYLON {
  55861. /** @hidden */
  55862. export var pbrUboDeclaration: {
  55863. name: string;
  55864. shader: string;
  55865. };
  55866. }
  55867. declare module BABYLON {
  55868. /** @hidden */
  55869. export var pbrFragmentExtraDeclaration: {
  55870. name: string;
  55871. shader: string;
  55872. };
  55873. }
  55874. declare module BABYLON {
  55875. /** @hidden */
  55876. export var pbrFragmentSamplersDeclaration: {
  55877. name: string;
  55878. shader: string;
  55879. };
  55880. }
  55881. declare module BABYLON {
  55882. /** @hidden */
  55883. export var importanceSampling: {
  55884. name: string;
  55885. shader: string;
  55886. };
  55887. }
  55888. declare module BABYLON {
  55889. /** @hidden */
  55890. export var pbrHelperFunctions: {
  55891. name: string;
  55892. shader: string;
  55893. };
  55894. }
  55895. declare module BABYLON {
  55896. /** @hidden */
  55897. export var harmonicsFunctions: {
  55898. name: string;
  55899. shader: string;
  55900. };
  55901. }
  55902. declare module BABYLON {
  55903. /** @hidden */
  55904. export var pbrDirectLightingSetupFunctions: {
  55905. name: string;
  55906. shader: string;
  55907. };
  55908. }
  55909. declare module BABYLON {
  55910. /** @hidden */
  55911. export var pbrDirectLightingFalloffFunctions: {
  55912. name: string;
  55913. shader: string;
  55914. };
  55915. }
  55916. declare module BABYLON {
  55917. /** @hidden */
  55918. export var pbrBRDFFunctions: {
  55919. name: string;
  55920. shader: string;
  55921. };
  55922. }
  55923. declare module BABYLON {
  55924. /** @hidden */
  55925. export var hdrFilteringFunctions: {
  55926. name: string;
  55927. shader: string;
  55928. };
  55929. }
  55930. declare module BABYLON {
  55931. /** @hidden */
  55932. export var pbrDirectLightingFunctions: {
  55933. name: string;
  55934. shader: string;
  55935. };
  55936. }
  55937. declare module BABYLON {
  55938. /** @hidden */
  55939. export var pbrIBLFunctions: {
  55940. name: string;
  55941. shader: string;
  55942. };
  55943. }
  55944. declare module BABYLON {
  55945. /** @hidden */
  55946. export var pbrBlockAlbedoOpacity: {
  55947. name: string;
  55948. shader: string;
  55949. };
  55950. }
  55951. declare module BABYLON {
  55952. /** @hidden */
  55953. export var pbrBlockReflectivity: {
  55954. name: string;
  55955. shader: string;
  55956. };
  55957. }
  55958. declare module BABYLON {
  55959. /** @hidden */
  55960. export var pbrBlockAmbientOcclusion: {
  55961. name: string;
  55962. shader: string;
  55963. };
  55964. }
  55965. declare module BABYLON {
  55966. /** @hidden */
  55967. export var pbrBlockAlphaFresnel: {
  55968. name: string;
  55969. shader: string;
  55970. };
  55971. }
  55972. declare module BABYLON {
  55973. /** @hidden */
  55974. export var pbrBlockAnisotropic: {
  55975. name: string;
  55976. shader: string;
  55977. };
  55978. }
  55979. declare module BABYLON {
  55980. /** @hidden */
  55981. export var pbrBlockReflection: {
  55982. name: string;
  55983. shader: string;
  55984. };
  55985. }
  55986. declare module BABYLON {
  55987. /** @hidden */
  55988. export var pbrBlockSheen: {
  55989. name: string;
  55990. shader: string;
  55991. };
  55992. }
  55993. declare module BABYLON {
  55994. /** @hidden */
  55995. export var pbrBlockClearcoat: {
  55996. name: string;
  55997. shader: string;
  55998. };
  55999. }
  56000. declare module BABYLON {
  56001. /** @hidden */
  56002. export var pbrBlockSubSurface: {
  56003. name: string;
  56004. shader: string;
  56005. };
  56006. }
  56007. declare module BABYLON {
  56008. /** @hidden */
  56009. export var pbrBlockNormalGeometric: {
  56010. name: string;
  56011. shader: string;
  56012. };
  56013. }
  56014. declare module BABYLON {
  56015. /** @hidden */
  56016. export var pbrBlockNormalFinal: {
  56017. name: string;
  56018. shader: string;
  56019. };
  56020. }
  56021. declare module BABYLON {
  56022. /** @hidden */
  56023. export var pbrBlockLightmapInit: {
  56024. name: string;
  56025. shader: string;
  56026. };
  56027. }
  56028. declare module BABYLON {
  56029. /** @hidden */
  56030. export var pbrBlockGeometryInfo: {
  56031. name: string;
  56032. shader: string;
  56033. };
  56034. }
  56035. declare module BABYLON {
  56036. /** @hidden */
  56037. export var pbrBlockReflectance0: {
  56038. name: string;
  56039. shader: string;
  56040. };
  56041. }
  56042. declare module BABYLON {
  56043. /** @hidden */
  56044. export var pbrBlockReflectance: {
  56045. name: string;
  56046. shader: string;
  56047. };
  56048. }
  56049. declare module BABYLON {
  56050. /** @hidden */
  56051. export var pbrBlockDirectLighting: {
  56052. name: string;
  56053. shader: string;
  56054. };
  56055. }
  56056. declare module BABYLON {
  56057. /** @hidden */
  56058. export var pbrBlockFinalLitComponents: {
  56059. name: string;
  56060. shader: string;
  56061. };
  56062. }
  56063. declare module BABYLON {
  56064. /** @hidden */
  56065. export var pbrBlockFinalUnlitComponents: {
  56066. name: string;
  56067. shader: string;
  56068. };
  56069. }
  56070. declare module BABYLON {
  56071. /** @hidden */
  56072. export var pbrBlockFinalColorComposition: {
  56073. name: string;
  56074. shader: string;
  56075. };
  56076. }
  56077. declare module BABYLON {
  56078. /** @hidden */
  56079. export var pbrBlockImageProcessing: {
  56080. name: string;
  56081. shader: string;
  56082. };
  56083. }
  56084. declare module BABYLON {
  56085. /** @hidden */
  56086. export var pbrDebug: {
  56087. name: string;
  56088. shader: string;
  56089. };
  56090. }
  56091. declare module BABYLON {
  56092. /** @hidden */
  56093. export var pbrPixelShader: {
  56094. name: string;
  56095. shader: string;
  56096. };
  56097. }
  56098. declare module BABYLON {
  56099. /** @hidden */
  56100. export var pbrVertexDeclaration: {
  56101. name: string;
  56102. shader: string;
  56103. };
  56104. }
  56105. declare module BABYLON {
  56106. /** @hidden */
  56107. export var pbrVertexShader: {
  56108. name: string;
  56109. shader: string;
  56110. };
  56111. }
  56112. declare module BABYLON {
  56113. /**
  56114. * Manages the defines for the PBR Material.
  56115. * @hidden
  56116. */
  56117. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56118. PBR: boolean;
  56119. NUM_SAMPLES: string;
  56120. REALTIME_FILTERING: boolean;
  56121. MAINUV1: boolean;
  56122. MAINUV2: boolean;
  56123. UV1: boolean;
  56124. UV2: boolean;
  56125. ALBEDO: boolean;
  56126. GAMMAALBEDO: boolean;
  56127. ALBEDODIRECTUV: number;
  56128. VERTEXCOLOR: boolean;
  56129. DETAIL: boolean;
  56130. DETAILDIRECTUV: number;
  56131. DETAIL_NORMALBLENDMETHOD: number;
  56132. AMBIENT: boolean;
  56133. AMBIENTDIRECTUV: number;
  56134. AMBIENTINGRAYSCALE: boolean;
  56135. OPACITY: boolean;
  56136. VERTEXALPHA: boolean;
  56137. OPACITYDIRECTUV: number;
  56138. OPACITYRGB: boolean;
  56139. ALPHATEST: boolean;
  56140. DEPTHPREPASS: boolean;
  56141. ALPHABLEND: boolean;
  56142. ALPHAFROMALBEDO: boolean;
  56143. ALPHATESTVALUE: string;
  56144. SPECULAROVERALPHA: boolean;
  56145. RADIANCEOVERALPHA: boolean;
  56146. ALPHAFRESNEL: boolean;
  56147. LINEARALPHAFRESNEL: boolean;
  56148. PREMULTIPLYALPHA: boolean;
  56149. EMISSIVE: boolean;
  56150. EMISSIVEDIRECTUV: number;
  56151. REFLECTIVITY: boolean;
  56152. REFLECTIVITYDIRECTUV: number;
  56153. SPECULARTERM: boolean;
  56154. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56155. MICROSURFACEAUTOMATIC: boolean;
  56156. LODBASEDMICROSFURACE: boolean;
  56157. MICROSURFACEMAP: boolean;
  56158. MICROSURFACEMAPDIRECTUV: number;
  56159. METALLICWORKFLOW: boolean;
  56160. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56161. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56162. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56163. AOSTOREINMETALMAPRED: boolean;
  56164. METALLIC_REFLECTANCE: boolean;
  56165. METALLIC_REFLECTANCEDIRECTUV: number;
  56166. ENVIRONMENTBRDF: boolean;
  56167. ENVIRONMENTBRDF_RGBD: boolean;
  56168. NORMAL: boolean;
  56169. TANGENT: boolean;
  56170. BUMP: boolean;
  56171. BUMPDIRECTUV: number;
  56172. OBJECTSPACE_NORMALMAP: boolean;
  56173. PARALLAX: boolean;
  56174. PARALLAXOCCLUSION: boolean;
  56175. NORMALXYSCALE: boolean;
  56176. LIGHTMAP: boolean;
  56177. LIGHTMAPDIRECTUV: number;
  56178. USELIGHTMAPASSHADOWMAP: boolean;
  56179. GAMMALIGHTMAP: boolean;
  56180. RGBDLIGHTMAP: boolean;
  56181. REFLECTION: boolean;
  56182. REFLECTIONMAP_3D: boolean;
  56183. REFLECTIONMAP_SPHERICAL: boolean;
  56184. REFLECTIONMAP_PLANAR: boolean;
  56185. REFLECTIONMAP_CUBIC: boolean;
  56186. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56187. REFLECTIONMAP_PROJECTION: boolean;
  56188. REFLECTIONMAP_SKYBOX: boolean;
  56189. REFLECTIONMAP_EXPLICIT: boolean;
  56190. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56191. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56192. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56193. INVERTCUBICMAP: boolean;
  56194. USESPHERICALFROMREFLECTIONMAP: boolean;
  56195. USEIRRADIANCEMAP: boolean;
  56196. SPHERICAL_HARMONICS: boolean;
  56197. USESPHERICALINVERTEX: boolean;
  56198. REFLECTIONMAP_OPPOSITEZ: boolean;
  56199. LODINREFLECTIONALPHA: boolean;
  56200. GAMMAREFLECTION: boolean;
  56201. RGBDREFLECTION: boolean;
  56202. LINEARSPECULARREFLECTION: boolean;
  56203. RADIANCEOCCLUSION: boolean;
  56204. HORIZONOCCLUSION: boolean;
  56205. INSTANCES: boolean;
  56206. THIN_INSTANCES: boolean;
  56207. PREPASS: boolean;
  56208. SCENE_MRT_COUNT: number;
  56209. NUM_BONE_INFLUENCERS: number;
  56210. BonesPerMesh: number;
  56211. BONETEXTURE: boolean;
  56212. NONUNIFORMSCALING: boolean;
  56213. MORPHTARGETS: boolean;
  56214. MORPHTARGETS_NORMAL: boolean;
  56215. MORPHTARGETS_TANGENT: boolean;
  56216. MORPHTARGETS_UV: boolean;
  56217. NUM_MORPH_INFLUENCERS: number;
  56218. IMAGEPROCESSING: boolean;
  56219. VIGNETTE: boolean;
  56220. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56221. VIGNETTEBLENDMODEOPAQUE: boolean;
  56222. TONEMAPPING: boolean;
  56223. TONEMAPPING_ACES: boolean;
  56224. CONTRAST: boolean;
  56225. COLORCURVES: boolean;
  56226. COLORGRADING: boolean;
  56227. COLORGRADING3D: boolean;
  56228. SAMPLER3DGREENDEPTH: boolean;
  56229. SAMPLER3DBGRMAP: boolean;
  56230. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56231. EXPOSURE: boolean;
  56232. MULTIVIEW: boolean;
  56233. USEPHYSICALLIGHTFALLOFF: boolean;
  56234. USEGLTFLIGHTFALLOFF: boolean;
  56235. TWOSIDEDLIGHTING: boolean;
  56236. SHADOWFLOAT: boolean;
  56237. CLIPPLANE: boolean;
  56238. CLIPPLANE2: boolean;
  56239. CLIPPLANE3: boolean;
  56240. CLIPPLANE4: boolean;
  56241. CLIPPLANE5: boolean;
  56242. CLIPPLANE6: boolean;
  56243. POINTSIZE: boolean;
  56244. FOG: boolean;
  56245. LOGARITHMICDEPTH: boolean;
  56246. FORCENORMALFORWARD: boolean;
  56247. SPECULARAA: boolean;
  56248. CLEARCOAT: boolean;
  56249. CLEARCOAT_DEFAULTIOR: boolean;
  56250. CLEARCOAT_TEXTURE: boolean;
  56251. CLEARCOAT_TEXTUREDIRECTUV: number;
  56252. CLEARCOAT_BUMP: boolean;
  56253. CLEARCOAT_BUMPDIRECTUV: number;
  56254. CLEARCOAT_TINT: boolean;
  56255. CLEARCOAT_TINT_TEXTURE: boolean;
  56256. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56257. ANISOTROPIC: boolean;
  56258. ANISOTROPIC_TEXTURE: boolean;
  56259. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56260. BRDF_V_HEIGHT_CORRELATED: boolean;
  56261. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56262. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56263. SHEEN: boolean;
  56264. SHEEN_TEXTURE: boolean;
  56265. SHEEN_TEXTUREDIRECTUV: number;
  56266. SHEEN_LINKWITHALBEDO: boolean;
  56267. SHEEN_ROUGHNESS: boolean;
  56268. SHEEN_ALBEDOSCALING: boolean;
  56269. SUBSURFACE: boolean;
  56270. SS_REFRACTION: boolean;
  56271. SS_TRANSLUCENCY: boolean;
  56272. SS_SCATTERING: boolean;
  56273. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56274. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56275. SS_REFRACTIONMAP_3D: boolean;
  56276. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56277. SS_LODINREFRACTIONALPHA: boolean;
  56278. SS_GAMMAREFRACTION: boolean;
  56279. SS_RGBDREFRACTION: boolean;
  56280. SS_LINEARSPECULARREFRACTION: boolean;
  56281. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56282. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56283. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56284. UNLIT: boolean;
  56285. DEBUGMODE: number;
  56286. /**
  56287. * Initializes the PBR Material defines.
  56288. */
  56289. constructor();
  56290. /**
  56291. * Resets the PBR Material defines.
  56292. */
  56293. reset(): void;
  56294. }
  56295. /**
  56296. * The Physically based material base class of BJS.
  56297. *
  56298. * This offers the main features of a standard PBR material.
  56299. * For more information, please refer to the documentation :
  56300. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56301. */
  56302. export abstract class PBRBaseMaterial extends PushMaterial {
  56303. /**
  56304. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56305. */
  56306. static readonly PBRMATERIAL_OPAQUE: number;
  56307. /**
  56308. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56309. */
  56310. static readonly PBRMATERIAL_ALPHATEST: number;
  56311. /**
  56312. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56313. */
  56314. static readonly PBRMATERIAL_ALPHABLEND: number;
  56315. /**
  56316. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56317. * They are also discarded below the alpha cutoff threshold to improve performances.
  56318. */
  56319. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56320. /**
  56321. * Defines the default value of how much AO map is occluding the analytical lights
  56322. * (point spot...).
  56323. */
  56324. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56325. /**
  56326. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56327. */
  56328. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56329. /**
  56330. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56331. * to enhance interoperability with other engines.
  56332. */
  56333. static readonly LIGHTFALLOFF_GLTF: number;
  56334. /**
  56335. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56336. * to enhance interoperability with other materials.
  56337. */
  56338. static readonly LIGHTFALLOFF_STANDARD: number;
  56339. /**
  56340. * Intensity of the direct lights e.g. the four lights available in your scene.
  56341. * This impacts both the direct diffuse and specular highlights.
  56342. */
  56343. protected _directIntensity: number;
  56344. /**
  56345. * Intensity of the emissive part of the material.
  56346. * This helps controlling the emissive effect without modifying the emissive color.
  56347. */
  56348. protected _emissiveIntensity: number;
  56349. /**
  56350. * Intensity of the environment e.g. how much the environment will light the object
  56351. * either through harmonics for rough material or through the refelction for shiny ones.
  56352. */
  56353. protected _environmentIntensity: number;
  56354. /**
  56355. * This is a special control allowing the reduction of the specular highlights coming from the
  56356. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56357. */
  56358. protected _specularIntensity: number;
  56359. /**
  56360. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56361. */
  56362. private _lightingInfos;
  56363. /**
  56364. * Debug Control allowing disabling the bump map on this material.
  56365. */
  56366. protected _disableBumpMap: boolean;
  56367. /**
  56368. * AKA Diffuse Texture in standard nomenclature.
  56369. */
  56370. protected _albedoTexture: Nullable<BaseTexture>;
  56371. /**
  56372. * AKA Occlusion Texture in other nomenclature.
  56373. */
  56374. protected _ambientTexture: Nullable<BaseTexture>;
  56375. /**
  56376. * AKA Occlusion Texture Intensity in other nomenclature.
  56377. */
  56378. protected _ambientTextureStrength: number;
  56379. /**
  56380. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56381. * 1 means it completely occludes it
  56382. * 0 mean it has no impact
  56383. */
  56384. protected _ambientTextureImpactOnAnalyticalLights: number;
  56385. /**
  56386. * Stores the alpha values in a texture.
  56387. */
  56388. protected _opacityTexture: Nullable<BaseTexture>;
  56389. /**
  56390. * Stores the reflection values in a texture.
  56391. */
  56392. protected _reflectionTexture: Nullable<BaseTexture>;
  56393. /**
  56394. * Stores the emissive values in a texture.
  56395. */
  56396. protected _emissiveTexture: Nullable<BaseTexture>;
  56397. /**
  56398. * AKA Specular texture in other nomenclature.
  56399. */
  56400. protected _reflectivityTexture: Nullable<BaseTexture>;
  56401. /**
  56402. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56403. */
  56404. protected _metallicTexture: Nullable<BaseTexture>;
  56405. /**
  56406. * Specifies the metallic scalar of the metallic/roughness workflow.
  56407. * Can also be used to scale the metalness values of the metallic texture.
  56408. */
  56409. protected _metallic: Nullable<number>;
  56410. /**
  56411. * Specifies the roughness scalar of the metallic/roughness workflow.
  56412. * Can also be used to scale the roughness values of the metallic texture.
  56413. */
  56414. protected _roughness: Nullable<number>;
  56415. /**
  56416. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56417. * By default the indexOfrefraction is used to compute F0;
  56418. *
  56419. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56420. *
  56421. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56422. * F90 = metallicReflectanceColor;
  56423. */
  56424. protected _metallicF0Factor: number;
  56425. /**
  56426. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56427. * By default the F90 is always 1;
  56428. *
  56429. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56430. *
  56431. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56432. * F90 = metallicReflectanceColor;
  56433. */
  56434. protected _metallicReflectanceColor: Color3;
  56435. /**
  56436. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56437. * This is multiply against the scalar values defined in the material.
  56438. */
  56439. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56440. /**
  56441. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56442. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56443. */
  56444. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56445. /**
  56446. * Stores surface normal data used to displace a mesh in a texture.
  56447. */
  56448. protected _bumpTexture: Nullable<BaseTexture>;
  56449. /**
  56450. * Stores the pre-calculated light information of a mesh in a texture.
  56451. */
  56452. protected _lightmapTexture: Nullable<BaseTexture>;
  56453. /**
  56454. * The color of a material in ambient lighting.
  56455. */
  56456. protected _ambientColor: Color3;
  56457. /**
  56458. * AKA Diffuse Color in other nomenclature.
  56459. */
  56460. protected _albedoColor: Color3;
  56461. /**
  56462. * AKA Specular Color in other nomenclature.
  56463. */
  56464. protected _reflectivityColor: Color3;
  56465. /**
  56466. * The color applied when light is reflected from a material.
  56467. */
  56468. protected _reflectionColor: Color3;
  56469. /**
  56470. * The color applied when light is emitted from a material.
  56471. */
  56472. protected _emissiveColor: Color3;
  56473. /**
  56474. * AKA Glossiness in other nomenclature.
  56475. */
  56476. protected _microSurface: number;
  56477. /**
  56478. * Specifies that the material will use the light map as a show map.
  56479. */
  56480. protected _useLightmapAsShadowmap: boolean;
  56481. /**
  56482. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56483. * makes the reflect vector face the model (under horizon).
  56484. */
  56485. protected _useHorizonOcclusion: boolean;
  56486. /**
  56487. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56488. * too much the area relying on ambient texture to define their ambient occlusion.
  56489. */
  56490. protected _useRadianceOcclusion: boolean;
  56491. /**
  56492. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56493. */
  56494. protected _useAlphaFromAlbedoTexture: boolean;
  56495. /**
  56496. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56497. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56498. */
  56499. protected _useSpecularOverAlpha: boolean;
  56500. /**
  56501. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56502. */
  56503. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56504. /**
  56505. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56506. */
  56507. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56508. /**
  56509. * Specifies if the metallic texture contains the roughness information in its green channel.
  56510. */
  56511. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56512. /**
  56513. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56514. */
  56515. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56516. /**
  56517. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56518. */
  56519. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56520. /**
  56521. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56522. */
  56523. protected _useAmbientInGrayScale: boolean;
  56524. /**
  56525. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56526. * The material will try to infer what glossiness each pixel should be.
  56527. */
  56528. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56529. /**
  56530. * Defines the falloff type used in this material.
  56531. * It by default is Physical.
  56532. */
  56533. protected _lightFalloff: number;
  56534. /**
  56535. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56536. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56537. */
  56538. protected _useRadianceOverAlpha: boolean;
  56539. /**
  56540. * Allows using an object space normal map (instead of tangent space).
  56541. */
  56542. protected _useObjectSpaceNormalMap: boolean;
  56543. /**
  56544. * Allows using the bump map in parallax mode.
  56545. */
  56546. protected _useParallax: boolean;
  56547. /**
  56548. * Allows using the bump map in parallax occlusion mode.
  56549. */
  56550. protected _useParallaxOcclusion: boolean;
  56551. /**
  56552. * Controls the scale bias of the parallax mode.
  56553. */
  56554. protected _parallaxScaleBias: number;
  56555. /**
  56556. * If sets to true, disables all the lights affecting the material.
  56557. */
  56558. protected _disableLighting: boolean;
  56559. /**
  56560. * Number of Simultaneous lights allowed on the material.
  56561. */
  56562. protected _maxSimultaneousLights: number;
  56563. /**
  56564. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56565. */
  56566. protected _invertNormalMapX: boolean;
  56567. /**
  56568. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56569. */
  56570. protected _invertNormalMapY: boolean;
  56571. /**
  56572. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56573. */
  56574. protected _twoSidedLighting: boolean;
  56575. /**
  56576. * Defines the alpha limits in alpha test mode.
  56577. */
  56578. protected _alphaCutOff: number;
  56579. /**
  56580. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56581. */
  56582. protected _forceAlphaTest: boolean;
  56583. /**
  56584. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56585. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56586. */
  56587. protected _useAlphaFresnel: boolean;
  56588. /**
  56589. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56590. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56591. */
  56592. protected _useLinearAlphaFresnel: boolean;
  56593. /**
  56594. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56595. * from cos thetav and roughness:
  56596. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56597. */
  56598. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56599. /**
  56600. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56601. */
  56602. protected _forceIrradianceInFragment: boolean;
  56603. private _realTimeFiltering;
  56604. /**
  56605. * Enables realtime filtering on the texture.
  56606. */
  56607. get realTimeFiltering(): boolean;
  56608. set realTimeFiltering(b: boolean);
  56609. private _realTimeFilteringQuality;
  56610. /**
  56611. * Quality switch for realtime filtering
  56612. */
  56613. get realTimeFilteringQuality(): number;
  56614. set realTimeFilteringQuality(n: number);
  56615. /**
  56616. * Can this material render to several textures at once
  56617. */
  56618. get canRenderToMRT(): boolean;
  56619. /**
  56620. * Force normal to face away from face.
  56621. */
  56622. protected _forceNormalForward: boolean;
  56623. /**
  56624. * Enables specular anti aliasing in the PBR shader.
  56625. * It will both interacts on the Geometry for analytical and IBL lighting.
  56626. * It also prefilter the roughness map based on the bump values.
  56627. */
  56628. protected _enableSpecularAntiAliasing: boolean;
  56629. /**
  56630. * Default configuration related to image processing available in the PBR Material.
  56631. */
  56632. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56633. /**
  56634. * Keep track of the image processing observer to allow dispose and replace.
  56635. */
  56636. private _imageProcessingObserver;
  56637. /**
  56638. * Attaches a new image processing configuration to the PBR Material.
  56639. * @param configuration
  56640. */
  56641. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56642. /**
  56643. * Stores the available render targets.
  56644. */
  56645. private _renderTargets;
  56646. /**
  56647. * Sets the global ambient color for the material used in lighting calculations.
  56648. */
  56649. private _globalAmbientColor;
  56650. /**
  56651. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56652. */
  56653. private _useLogarithmicDepth;
  56654. /**
  56655. * If set to true, no lighting calculations will be applied.
  56656. */
  56657. private _unlit;
  56658. private _debugMode;
  56659. /**
  56660. * @hidden
  56661. * This is reserved for the inspector.
  56662. * Defines the material debug mode.
  56663. * It helps seeing only some components of the material while troubleshooting.
  56664. */
  56665. debugMode: number;
  56666. /**
  56667. * @hidden
  56668. * This is reserved for the inspector.
  56669. * Specify from where on screen the debug mode should start.
  56670. * The value goes from -1 (full screen) to 1 (not visible)
  56671. * It helps with side by side comparison against the final render
  56672. * This defaults to -1
  56673. */
  56674. private debugLimit;
  56675. /**
  56676. * @hidden
  56677. * This is reserved for the inspector.
  56678. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56679. * You can use the factor to better multiply the final value.
  56680. */
  56681. private debugFactor;
  56682. /**
  56683. * Defines the clear coat layer parameters for the material.
  56684. */
  56685. readonly clearCoat: PBRClearCoatConfiguration;
  56686. /**
  56687. * Defines the anisotropic parameters for the material.
  56688. */
  56689. readonly anisotropy: PBRAnisotropicConfiguration;
  56690. /**
  56691. * Defines the BRDF parameters for the material.
  56692. */
  56693. readonly brdf: PBRBRDFConfiguration;
  56694. /**
  56695. * Defines the Sheen parameters for the material.
  56696. */
  56697. readonly sheen: PBRSheenConfiguration;
  56698. /**
  56699. * Defines the SubSurface parameters for the material.
  56700. */
  56701. readonly subSurface: PBRSubSurfaceConfiguration;
  56702. /**
  56703. * Defines the detail map parameters for the material.
  56704. */
  56705. readonly detailMap: DetailMapConfiguration;
  56706. protected _rebuildInParallel: boolean;
  56707. /**
  56708. * Instantiates a new PBRMaterial instance.
  56709. *
  56710. * @param name The material name
  56711. * @param scene The scene the material will be use in.
  56712. */
  56713. constructor(name: string, scene: Scene);
  56714. /**
  56715. * Gets a boolean indicating that current material needs to register RTT
  56716. */
  56717. get hasRenderTargetTextures(): boolean;
  56718. /**
  56719. * Gets the name of the material class.
  56720. */
  56721. getClassName(): string;
  56722. /**
  56723. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56724. */
  56725. get useLogarithmicDepth(): boolean;
  56726. /**
  56727. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56728. */
  56729. set useLogarithmicDepth(value: boolean);
  56730. /**
  56731. * Returns true if alpha blending should be disabled.
  56732. */
  56733. protected get _disableAlphaBlending(): boolean;
  56734. /**
  56735. * Specifies whether or not this material should be rendered in alpha blend mode.
  56736. */
  56737. needAlphaBlending(): boolean;
  56738. /**
  56739. * Specifies whether or not this material should be rendered in alpha test mode.
  56740. */
  56741. needAlphaTesting(): boolean;
  56742. /**
  56743. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56744. */
  56745. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56746. /**
  56747. * Gets the texture used for the alpha test.
  56748. */
  56749. getAlphaTestTexture(): Nullable<BaseTexture>;
  56750. /**
  56751. * Specifies that the submesh is ready to be used.
  56752. * @param mesh - BJS mesh.
  56753. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56754. * @param useInstances - Specifies that instances should be used.
  56755. * @returns - boolean indicating that the submesh is ready or not.
  56756. */
  56757. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56758. /**
  56759. * Specifies if the material uses metallic roughness workflow.
  56760. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56761. */
  56762. isMetallicWorkflow(): boolean;
  56763. private _prepareEffect;
  56764. private _prepareDefines;
  56765. /**
  56766. * Force shader compilation
  56767. */
  56768. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56769. /**
  56770. * Initializes the uniform buffer layout for the shader.
  56771. */
  56772. buildUniformLayout(): void;
  56773. /**
  56774. * Unbinds the material from the mesh
  56775. */
  56776. unbind(): void;
  56777. /**
  56778. * Binds the submesh data.
  56779. * @param world - The world matrix.
  56780. * @param mesh - The BJS mesh.
  56781. * @param subMesh - A submesh of the BJS mesh.
  56782. */
  56783. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56784. /**
  56785. * Returns the animatable textures.
  56786. * @returns - Array of animatable textures.
  56787. */
  56788. getAnimatables(): IAnimatable[];
  56789. /**
  56790. * Returns the texture used for reflections.
  56791. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56792. */
  56793. private _getReflectionTexture;
  56794. /**
  56795. * Returns an array of the actively used textures.
  56796. * @returns - Array of BaseTextures
  56797. */
  56798. getActiveTextures(): BaseTexture[];
  56799. /**
  56800. * Checks to see if a texture is used in the material.
  56801. * @param texture - Base texture to use.
  56802. * @returns - Boolean specifying if a texture is used in the material.
  56803. */
  56804. hasTexture(texture: BaseTexture): boolean;
  56805. /**
  56806. * Sets the required values to the prepass renderer.
  56807. * @param prePassRenderer defines the prepass renderer to setup
  56808. */
  56809. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56810. /**
  56811. * Disposes the resources of the material.
  56812. * @param forceDisposeEffect - Forces the disposal of effects.
  56813. * @param forceDisposeTextures - Forces the disposal of all textures.
  56814. */
  56815. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56816. }
  56817. }
  56818. declare module BABYLON {
  56819. /**
  56820. * The Physically based material of BJS.
  56821. *
  56822. * This offers the main features of a standard PBR material.
  56823. * For more information, please refer to the documentation :
  56824. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56825. */
  56826. export class PBRMaterial extends PBRBaseMaterial {
  56827. /**
  56828. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56829. */
  56830. static readonly PBRMATERIAL_OPAQUE: number;
  56831. /**
  56832. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56833. */
  56834. static readonly PBRMATERIAL_ALPHATEST: number;
  56835. /**
  56836. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56837. */
  56838. static readonly PBRMATERIAL_ALPHABLEND: number;
  56839. /**
  56840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56841. * They are also discarded below the alpha cutoff threshold to improve performances.
  56842. */
  56843. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56844. /**
  56845. * Defines the default value of how much AO map is occluding the analytical lights
  56846. * (point spot...).
  56847. */
  56848. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56849. /**
  56850. * Intensity of the direct lights e.g. the four lights available in your scene.
  56851. * This impacts both the direct diffuse and specular highlights.
  56852. */
  56853. directIntensity: number;
  56854. /**
  56855. * Intensity of the emissive part of the material.
  56856. * This helps controlling the emissive effect without modifying the emissive color.
  56857. */
  56858. emissiveIntensity: number;
  56859. /**
  56860. * Intensity of the environment e.g. how much the environment will light the object
  56861. * either through harmonics for rough material or through the refelction for shiny ones.
  56862. */
  56863. environmentIntensity: number;
  56864. /**
  56865. * This is a special control allowing the reduction of the specular highlights coming from the
  56866. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56867. */
  56868. specularIntensity: number;
  56869. /**
  56870. * Debug Control allowing disabling the bump map on this material.
  56871. */
  56872. disableBumpMap: boolean;
  56873. /**
  56874. * AKA Diffuse Texture in standard nomenclature.
  56875. */
  56876. albedoTexture: BaseTexture;
  56877. /**
  56878. * AKA Occlusion Texture in other nomenclature.
  56879. */
  56880. ambientTexture: BaseTexture;
  56881. /**
  56882. * AKA Occlusion Texture Intensity in other nomenclature.
  56883. */
  56884. ambientTextureStrength: number;
  56885. /**
  56886. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56887. * 1 means it completely occludes it
  56888. * 0 mean it has no impact
  56889. */
  56890. ambientTextureImpactOnAnalyticalLights: number;
  56891. /**
  56892. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56893. */
  56894. opacityTexture: BaseTexture;
  56895. /**
  56896. * Stores the reflection values in a texture.
  56897. */
  56898. reflectionTexture: Nullable<BaseTexture>;
  56899. /**
  56900. * Stores the emissive values in a texture.
  56901. */
  56902. emissiveTexture: BaseTexture;
  56903. /**
  56904. * AKA Specular texture in other nomenclature.
  56905. */
  56906. reflectivityTexture: BaseTexture;
  56907. /**
  56908. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56909. */
  56910. metallicTexture: BaseTexture;
  56911. /**
  56912. * Specifies the metallic scalar of the metallic/roughness workflow.
  56913. * Can also be used to scale the metalness values of the metallic texture.
  56914. */
  56915. metallic: Nullable<number>;
  56916. /**
  56917. * Specifies the roughness scalar of the metallic/roughness workflow.
  56918. * Can also be used to scale the roughness values of the metallic texture.
  56919. */
  56920. roughness: Nullable<number>;
  56921. /**
  56922. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56923. * By default the indexOfrefraction is used to compute F0;
  56924. *
  56925. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56926. *
  56927. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56928. * F90 = metallicReflectanceColor;
  56929. */
  56930. metallicF0Factor: number;
  56931. /**
  56932. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56933. * By default the F90 is always 1;
  56934. *
  56935. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56936. *
  56937. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56938. * F90 = metallicReflectanceColor;
  56939. */
  56940. metallicReflectanceColor: Color3;
  56941. /**
  56942. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56943. * This is multiply against the scalar values defined in the material.
  56944. */
  56945. metallicReflectanceTexture: Nullable<BaseTexture>;
  56946. /**
  56947. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56948. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56949. */
  56950. microSurfaceTexture: BaseTexture;
  56951. /**
  56952. * Stores surface normal data used to displace a mesh in a texture.
  56953. */
  56954. bumpTexture: BaseTexture;
  56955. /**
  56956. * Stores the pre-calculated light information of a mesh in a texture.
  56957. */
  56958. lightmapTexture: BaseTexture;
  56959. /**
  56960. * Stores the refracted light information in a texture.
  56961. */
  56962. get refractionTexture(): Nullable<BaseTexture>;
  56963. set refractionTexture(value: Nullable<BaseTexture>);
  56964. /**
  56965. * The color of a material in ambient lighting.
  56966. */
  56967. ambientColor: Color3;
  56968. /**
  56969. * AKA Diffuse Color in other nomenclature.
  56970. */
  56971. albedoColor: Color3;
  56972. /**
  56973. * AKA Specular Color in other nomenclature.
  56974. */
  56975. reflectivityColor: Color3;
  56976. /**
  56977. * The color reflected from the material.
  56978. */
  56979. reflectionColor: Color3;
  56980. /**
  56981. * The color emitted from the material.
  56982. */
  56983. emissiveColor: Color3;
  56984. /**
  56985. * AKA Glossiness in other nomenclature.
  56986. */
  56987. microSurface: number;
  56988. /**
  56989. * Index of refraction of the material base layer.
  56990. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56991. *
  56992. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56993. *
  56994. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56995. */
  56996. get indexOfRefraction(): number;
  56997. set indexOfRefraction(value: number);
  56998. /**
  56999. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57000. */
  57001. get invertRefractionY(): boolean;
  57002. set invertRefractionY(value: boolean);
  57003. /**
  57004. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57005. * Materials half opaque for instance using refraction could benefit from this control.
  57006. */
  57007. get linkRefractionWithTransparency(): boolean;
  57008. set linkRefractionWithTransparency(value: boolean);
  57009. /**
  57010. * If true, the light map contains occlusion information instead of lighting info.
  57011. */
  57012. useLightmapAsShadowmap: boolean;
  57013. /**
  57014. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57015. */
  57016. useAlphaFromAlbedoTexture: boolean;
  57017. /**
  57018. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57019. */
  57020. forceAlphaTest: boolean;
  57021. /**
  57022. * Defines the alpha limits in alpha test mode.
  57023. */
  57024. alphaCutOff: number;
  57025. /**
  57026. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57027. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57028. */
  57029. useSpecularOverAlpha: boolean;
  57030. /**
  57031. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57032. */
  57033. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57034. /**
  57035. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57036. */
  57037. useRoughnessFromMetallicTextureAlpha: boolean;
  57038. /**
  57039. * Specifies if the metallic texture contains the roughness information in its green channel.
  57040. */
  57041. useRoughnessFromMetallicTextureGreen: boolean;
  57042. /**
  57043. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57044. */
  57045. useMetallnessFromMetallicTextureBlue: boolean;
  57046. /**
  57047. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57048. */
  57049. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57050. /**
  57051. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57052. */
  57053. useAmbientInGrayScale: boolean;
  57054. /**
  57055. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57056. * The material will try to infer what glossiness each pixel should be.
  57057. */
  57058. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57059. /**
  57060. * BJS is using an harcoded light falloff based on a manually sets up range.
  57061. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57062. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57063. */
  57064. get usePhysicalLightFalloff(): boolean;
  57065. /**
  57066. * BJS is using an harcoded light falloff based on a manually sets up range.
  57067. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57068. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57069. */
  57070. set usePhysicalLightFalloff(value: boolean);
  57071. /**
  57072. * In order to support the falloff compatibility with gltf, a special mode has been added
  57073. * to reproduce the gltf light falloff.
  57074. */
  57075. get useGLTFLightFalloff(): boolean;
  57076. /**
  57077. * In order to support the falloff compatibility with gltf, a special mode has been added
  57078. * to reproduce the gltf light falloff.
  57079. */
  57080. set useGLTFLightFalloff(value: boolean);
  57081. /**
  57082. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57083. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57084. */
  57085. useRadianceOverAlpha: boolean;
  57086. /**
  57087. * Allows using an object space normal map (instead of tangent space).
  57088. */
  57089. useObjectSpaceNormalMap: boolean;
  57090. /**
  57091. * Allows using the bump map in parallax mode.
  57092. */
  57093. useParallax: boolean;
  57094. /**
  57095. * Allows using the bump map in parallax occlusion mode.
  57096. */
  57097. useParallaxOcclusion: boolean;
  57098. /**
  57099. * Controls the scale bias of the parallax mode.
  57100. */
  57101. parallaxScaleBias: number;
  57102. /**
  57103. * If sets to true, disables all the lights affecting the material.
  57104. */
  57105. disableLighting: boolean;
  57106. /**
  57107. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57108. */
  57109. forceIrradianceInFragment: boolean;
  57110. /**
  57111. * Number of Simultaneous lights allowed on the material.
  57112. */
  57113. maxSimultaneousLights: number;
  57114. /**
  57115. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57116. */
  57117. invertNormalMapX: boolean;
  57118. /**
  57119. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57120. */
  57121. invertNormalMapY: boolean;
  57122. /**
  57123. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57124. */
  57125. twoSidedLighting: boolean;
  57126. /**
  57127. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57128. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57129. */
  57130. useAlphaFresnel: boolean;
  57131. /**
  57132. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57133. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57134. */
  57135. useLinearAlphaFresnel: boolean;
  57136. /**
  57137. * Let user defines the brdf lookup texture used for IBL.
  57138. * A default 8bit version is embedded but you could point at :
  57139. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57140. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57141. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57142. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57143. */
  57144. environmentBRDFTexture: Nullable<BaseTexture>;
  57145. /**
  57146. * Force normal to face away from face.
  57147. */
  57148. forceNormalForward: boolean;
  57149. /**
  57150. * Enables specular anti aliasing in the PBR shader.
  57151. * It will both interacts on the Geometry for analytical and IBL lighting.
  57152. * It also prefilter the roughness map based on the bump values.
  57153. */
  57154. enableSpecularAntiAliasing: boolean;
  57155. /**
  57156. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57157. * makes the reflect vector face the model (under horizon).
  57158. */
  57159. useHorizonOcclusion: boolean;
  57160. /**
  57161. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57162. * too much the area relying on ambient texture to define their ambient occlusion.
  57163. */
  57164. useRadianceOcclusion: boolean;
  57165. /**
  57166. * If set to true, no lighting calculations will be applied.
  57167. */
  57168. unlit: boolean;
  57169. /**
  57170. * Gets the image processing configuration used either in this material.
  57171. */
  57172. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57173. /**
  57174. * Sets the Default image processing configuration used either in the this material.
  57175. *
  57176. * If sets to null, the scene one is in use.
  57177. */
  57178. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57179. /**
  57180. * Gets wether the color curves effect is enabled.
  57181. */
  57182. get cameraColorCurvesEnabled(): boolean;
  57183. /**
  57184. * Sets wether the color curves effect is enabled.
  57185. */
  57186. set cameraColorCurvesEnabled(value: boolean);
  57187. /**
  57188. * Gets wether the color grading effect is enabled.
  57189. */
  57190. get cameraColorGradingEnabled(): boolean;
  57191. /**
  57192. * Gets wether the color grading effect is enabled.
  57193. */
  57194. set cameraColorGradingEnabled(value: boolean);
  57195. /**
  57196. * Gets wether tonemapping is enabled or not.
  57197. */
  57198. get cameraToneMappingEnabled(): boolean;
  57199. /**
  57200. * Sets wether tonemapping is enabled or not
  57201. */
  57202. set cameraToneMappingEnabled(value: boolean);
  57203. /**
  57204. * The camera exposure used on this material.
  57205. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57206. * This corresponds to a photographic exposure.
  57207. */
  57208. get cameraExposure(): number;
  57209. /**
  57210. * The camera exposure used on this material.
  57211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57212. * This corresponds to a photographic exposure.
  57213. */
  57214. set cameraExposure(value: number);
  57215. /**
  57216. * Gets The camera contrast used on this material.
  57217. */
  57218. get cameraContrast(): number;
  57219. /**
  57220. * Sets The camera contrast used on this material.
  57221. */
  57222. set cameraContrast(value: number);
  57223. /**
  57224. * Gets the Color Grading 2D Lookup Texture.
  57225. */
  57226. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57227. /**
  57228. * Sets the Color Grading 2D Lookup Texture.
  57229. */
  57230. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57231. /**
  57232. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57233. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57234. * 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;
  57235. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57236. */
  57237. get cameraColorCurves(): Nullable<ColorCurves>;
  57238. /**
  57239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57241. * 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;
  57242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57243. */
  57244. set cameraColorCurves(value: Nullable<ColorCurves>);
  57245. /**
  57246. * Instantiates a new PBRMaterial instance.
  57247. *
  57248. * @param name The material name
  57249. * @param scene The scene the material will be use in.
  57250. */
  57251. constructor(name: string, scene: Scene);
  57252. /**
  57253. * Returns the name of this material class.
  57254. */
  57255. getClassName(): string;
  57256. /**
  57257. * Makes a duplicate of the current material.
  57258. * @param name - name to use for the new material.
  57259. */
  57260. clone(name: string): PBRMaterial;
  57261. /**
  57262. * Serializes this PBR Material.
  57263. * @returns - An object with the serialized material.
  57264. */
  57265. serialize(): any;
  57266. /**
  57267. * Parses a PBR Material from a serialized object.
  57268. * @param source - Serialized object.
  57269. * @param scene - BJS scene instance.
  57270. * @param rootUrl - url for the scene object
  57271. * @returns - PBRMaterial
  57272. */
  57273. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57274. }
  57275. }
  57276. declare module BABYLON {
  57277. /**
  57278. * Direct draw surface info
  57279. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57280. */
  57281. export interface DDSInfo {
  57282. /**
  57283. * Width of the texture
  57284. */
  57285. width: number;
  57286. /**
  57287. * Width of the texture
  57288. */
  57289. height: number;
  57290. /**
  57291. * Number of Mipmaps for the texture
  57292. * @see https://en.wikipedia.org/wiki/Mipmap
  57293. */
  57294. mipmapCount: number;
  57295. /**
  57296. * If the textures format is a known fourCC format
  57297. * @see https://www.fourcc.org/
  57298. */
  57299. isFourCC: boolean;
  57300. /**
  57301. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57302. */
  57303. isRGB: boolean;
  57304. /**
  57305. * If the texture is a lumincance format
  57306. */
  57307. isLuminance: boolean;
  57308. /**
  57309. * If this is a cube texture
  57310. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57311. */
  57312. isCube: boolean;
  57313. /**
  57314. * If the texture is a compressed format eg. FOURCC_DXT1
  57315. */
  57316. isCompressed: boolean;
  57317. /**
  57318. * The dxgiFormat of the texture
  57319. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57320. */
  57321. dxgiFormat: number;
  57322. /**
  57323. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57324. */
  57325. textureType: number;
  57326. /**
  57327. * Sphericle polynomial created for the dds texture
  57328. */
  57329. sphericalPolynomial?: SphericalPolynomial;
  57330. }
  57331. /**
  57332. * Class used to provide DDS decompression tools
  57333. */
  57334. export class DDSTools {
  57335. /**
  57336. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57337. */
  57338. static StoreLODInAlphaChannel: boolean;
  57339. /**
  57340. * Gets DDS information from an array buffer
  57341. * @param data defines the array buffer view to read data from
  57342. * @returns the DDS information
  57343. */
  57344. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57345. private static _FloatView;
  57346. private static _Int32View;
  57347. private static _ToHalfFloat;
  57348. private static _FromHalfFloat;
  57349. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57350. private static _GetHalfFloatRGBAArrayBuffer;
  57351. private static _GetFloatRGBAArrayBuffer;
  57352. private static _GetFloatAsUIntRGBAArrayBuffer;
  57353. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57354. private static _GetRGBAArrayBuffer;
  57355. private static _ExtractLongWordOrder;
  57356. private static _GetRGBArrayBuffer;
  57357. private static _GetLuminanceArrayBuffer;
  57358. /**
  57359. * Uploads DDS Levels to a Babylon Texture
  57360. * @hidden
  57361. */
  57362. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57363. }
  57364. interface ThinEngine {
  57365. /**
  57366. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57367. * @param rootUrl defines the url where the file to load is located
  57368. * @param scene defines the current scene
  57369. * @param lodScale defines scale to apply to the mip map selection
  57370. * @param lodOffset defines offset to apply to the mip map selection
  57371. * @param onLoad defines an optional callback raised when the texture is loaded
  57372. * @param onError defines an optional callback raised if there is an issue to load the texture
  57373. * @param format defines the format of the data
  57374. * @param forcedExtension defines the extension to use to pick the right loader
  57375. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57376. * @returns the cube texture as an InternalTexture
  57377. */
  57378. 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;
  57379. }
  57380. }
  57381. declare module BABYLON {
  57382. /**
  57383. * Implementation of the DDS Texture Loader.
  57384. * @hidden
  57385. */
  57386. export class _DDSTextureLoader implements IInternalTextureLoader {
  57387. /**
  57388. * Defines wether the loader supports cascade loading the different faces.
  57389. */
  57390. readonly supportCascades: boolean;
  57391. /**
  57392. * This returns if the loader support the current file information.
  57393. * @param extension defines the file extension of the file being loaded
  57394. * @returns true if the loader can load the specified file
  57395. */
  57396. canLoad(extension: string): boolean;
  57397. /**
  57398. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57399. * @param data contains the texture data
  57400. * @param texture defines the BabylonJS internal texture
  57401. * @param createPolynomials will be true if polynomials have been requested
  57402. * @param onLoad defines the callback to trigger once the texture is ready
  57403. * @param onError defines the callback to trigger in case of error
  57404. */
  57405. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57406. /**
  57407. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57408. * @param data contains the texture data
  57409. * @param texture defines the BabylonJS internal texture
  57410. * @param callback defines the method to call once ready to upload
  57411. */
  57412. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57413. }
  57414. }
  57415. declare module BABYLON {
  57416. /**
  57417. * Implementation of the ENV Texture Loader.
  57418. * @hidden
  57419. */
  57420. export class _ENVTextureLoader implements IInternalTextureLoader {
  57421. /**
  57422. * Defines wether the loader supports cascade loading the different faces.
  57423. */
  57424. readonly supportCascades: boolean;
  57425. /**
  57426. * This returns if the loader support the current file information.
  57427. * @param extension defines the file extension of the file being loaded
  57428. * @returns true if the loader can load the specified file
  57429. */
  57430. canLoad(extension: string): boolean;
  57431. /**
  57432. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57433. * @param data contains the texture data
  57434. * @param texture defines the BabylonJS internal texture
  57435. * @param createPolynomials will be true if polynomials have been requested
  57436. * @param onLoad defines the callback to trigger once the texture is ready
  57437. * @param onError defines the callback to trigger in case of error
  57438. */
  57439. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57440. /**
  57441. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57442. * @param data contains the texture data
  57443. * @param texture defines the BabylonJS internal texture
  57444. * @param callback defines the method to call once ready to upload
  57445. */
  57446. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57447. }
  57448. }
  57449. declare module BABYLON {
  57450. /**
  57451. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57452. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57453. */
  57454. export class KhronosTextureContainer {
  57455. /** contents of the KTX container file */
  57456. data: ArrayBufferView;
  57457. private static HEADER_LEN;
  57458. private static COMPRESSED_2D;
  57459. private static COMPRESSED_3D;
  57460. private static TEX_2D;
  57461. private static TEX_3D;
  57462. /**
  57463. * Gets the openGL type
  57464. */
  57465. glType: number;
  57466. /**
  57467. * Gets the openGL type size
  57468. */
  57469. glTypeSize: number;
  57470. /**
  57471. * Gets the openGL format
  57472. */
  57473. glFormat: number;
  57474. /**
  57475. * Gets the openGL internal format
  57476. */
  57477. glInternalFormat: number;
  57478. /**
  57479. * Gets the base internal format
  57480. */
  57481. glBaseInternalFormat: number;
  57482. /**
  57483. * Gets image width in pixel
  57484. */
  57485. pixelWidth: number;
  57486. /**
  57487. * Gets image height in pixel
  57488. */
  57489. pixelHeight: number;
  57490. /**
  57491. * Gets image depth in pixels
  57492. */
  57493. pixelDepth: number;
  57494. /**
  57495. * Gets the number of array elements
  57496. */
  57497. numberOfArrayElements: number;
  57498. /**
  57499. * Gets the number of faces
  57500. */
  57501. numberOfFaces: number;
  57502. /**
  57503. * Gets the number of mipmap levels
  57504. */
  57505. numberOfMipmapLevels: number;
  57506. /**
  57507. * Gets the bytes of key value data
  57508. */
  57509. bytesOfKeyValueData: number;
  57510. /**
  57511. * Gets the load type
  57512. */
  57513. loadType: number;
  57514. /**
  57515. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57516. */
  57517. isInvalid: boolean;
  57518. /**
  57519. * Creates a new KhronosTextureContainer
  57520. * @param data contents of the KTX container file
  57521. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57522. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57523. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57524. */
  57525. constructor(
  57526. /** contents of the KTX container file */
  57527. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57528. /**
  57529. * Uploads KTX content to a Babylon Texture.
  57530. * It is assumed that the texture has already been created & is currently bound
  57531. * @hidden
  57532. */
  57533. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57534. private _upload2DCompressedLevels;
  57535. /**
  57536. * Checks if the given data starts with a KTX file identifier.
  57537. * @param data the data to check
  57538. * @returns true if the data is a KTX file or false otherwise
  57539. */
  57540. static IsValid(data: ArrayBufferView): boolean;
  57541. }
  57542. }
  57543. declare module BABYLON {
  57544. /**
  57545. * Class for loading KTX2 files
  57546. * !!! Experimental Extension Subject to Changes !!!
  57547. * @hidden
  57548. */
  57549. export class KhronosTextureContainer2 {
  57550. private static _ModulePromise;
  57551. private static _TranscodeFormat;
  57552. constructor(engine: ThinEngine);
  57553. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57554. private _determineTranscodeFormat;
  57555. /**
  57556. * Checks if the given data starts with a KTX2 file identifier.
  57557. * @param data the data to check
  57558. * @returns true if the data is a KTX2 file or false otherwise
  57559. */
  57560. static IsValid(data: ArrayBufferView): boolean;
  57561. }
  57562. }
  57563. declare module BABYLON {
  57564. /**
  57565. * Implementation of the KTX Texture Loader.
  57566. * @hidden
  57567. */
  57568. export class _KTXTextureLoader implements IInternalTextureLoader {
  57569. /**
  57570. * Defines wether the loader supports cascade loading the different faces.
  57571. */
  57572. readonly supportCascades: boolean;
  57573. /**
  57574. * This returns if the loader support the current file information.
  57575. * @param extension defines the file extension of the file being loaded
  57576. * @param mimeType defines the optional mime type of the file being loaded
  57577. * @returns true if the loader can load the specified file
  57578. */
  57579. canLoad(extension: string, mimeType?: string): boolean;
  57580. /**
  57581. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57582. * @param data contains the texture data
  57583. * @param texture defines the BabylonJS internal texture
  57584. * @param createPolynomials will be true if polynomials have been requested
  57585. * @param onLoad defines the callback to trigger once the texture is ready
  57586. * @param onError defines the callback to trigger in case of error
  57587. */
  57588. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57589. /**
  57590. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57591. * @param data contains the texture data
  57592. * @param texture defines the BabylonJS internal texture
  57593. * @param callback defines the method to call once ready to upload
  57594. */
  57595. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57596. }
  57597. }
  57598. declare module BABYLON {
  57599. /** @hidden */
  57600. export var _forceSceneHelpersToBundle: boolean;
  57601. interface Scene {
  57602. /**
  57603. * Creates a default light for the scene.
  57604. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57605. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57606. */
  57607. createDefaultLight(replace?: boolean): void;
  57608. /**
  57609. * Creates a default camera for the scene.
  57610. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57611. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57612. * @param replace has default false, when true replaces the active camera in the scene
  57613. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57614. */
  57615. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57616. /**
  57617. * Creates a default camera and a default light.
  57618. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57619. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57620. * @param replace has the default false, when true replaces the active camera/light in the scene
  57621. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57622. */
  57623. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57624. /**
  57625. * Creates a new sky box
  57626. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57627. * @param environmentTexture defines the texture to use as environment texture
  57628. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57629. * @param scale defines the overall scale of the skybox
  57630. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57631. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57632. * @returns a new mesh holding the sky box
  57633. */
  57634. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57635. /**
  57636. * Creates a new environment
  57637. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57638. * @param options defines the options you can use to configure the environment
  57639. * @returns the new EnvironmentHelper
  57640. */
  57641. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57642. /**
  57643. * Creates a new VREXperienceHelper
  57644. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57645. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57646. * @returns a new VREXperienceHelper
  57647. */
  57648. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57649. /**
  57650. * Creates a new WebXRDefaultExperience
  57651. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57652. * @param options experience options
  57653. * @returns a promise for a new WebXRDefaultExperience
  57654. */
  57655. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57656. }
  57657. }
  57658. declare module BABYLON {
  57659. /**
  57660. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57661. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57662. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57663. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57664. */
  57665. export class VideoDome extends TransformNode {
  57666. /**
  57667. * Define the video source as a Monoscopic panoramic 360 video.
  57668. */
  57669. static readonly MODE_MONOSCOPIC: number;
  57670. /**
  57671. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57672. */
  57673. static readonly MODE_TOPBOTTOM: number;
  57674. /**
  57675. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57676. */
  57677. static readonly MODE_SIDEBYSIDE: number;
  57678. private _halfDome;
  57679. private _useDirectMapping;
  57680. /**
  57681. * The video texture being displayed on the sphere
  57682. */
  57683. protected _videoTexture: VideoTexture;
  57684. /**
  57685. * Gets the video texture being displayed on the sphere
  57686. */
  57687. get videoTexture(): VideoTexture;
  57688. /**
  57689. * The skybox material
  57690. */
  57691. protected _material: BackgroundMaterial;
  57692. /**
  57693. * The surface used for the video dome
  57694. */
  57695. protected _mesh: Mesh;
  57696. /**
  57697. * Gets the mesh used for the video dome.
  57698. */
  57699. get mesh(): Mesh;
  57700. /**
  57701. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57702. */
  57703. private _halfDomeMask;
  57704. /**
  57705. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57706. * Also see the options.resolution property.
  57707. */
  57708. get fovMultiplier(): number;
  57709. set fovMultiplier(value: number);
  57710. private _videoMode;
  57711. /**
  57712. * Gets or set the current video mode for the video. It can be:
  57713. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57714. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57715. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57716. */
  57717. get videoMode(): number;
  57718. set videoMode(value: number);
  57719. /**
  57720. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57721. *
  57722. */
  57723. get halfDome(): boolean;
  57724. /**
  57725. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57726. */
  57727. set halfDome(enabled: boolean);
  57728. /**
  57729. * Oberserver used in Stereoscopic VR Mode.
  57730. */
  57731. private _onBeforeCameraRenderObserver;
  57732. /**
  57733. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57734. * @param name Element's name, child elements will append suffixes for their own names.
  57735. * @param urlsOrVideo defines the url(s) or the video element to use
  57736. * @param options An object containing optional or exposed sub element properties
  57737. */
  57738. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57739. resolution?: number;
  57740. clickToPlay?: boolean;
  57741. autoPlay?: boolean;
  57742. loop?: boolean;
  57743. size?: number;
  57744. poster?: string;
  57745. faceForward?: boolean;
  57746. useDirectMapping?: boolean;
  57747. halfDomeMode?: boolean;
  57748. }, scene: Scene);
  57749. private _changeVideoMode;
  57750. /**
  57751. * Releases resources associated with this node.
  57752. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57753. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57754. */
  57755. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57756. }
  57757. }
  57758. declare module BABYLON {
  57759. /**
  57760. * This class can be used to get instrumentation data from a Babylon engine
  57761. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57762. */
  57763. export class EngineInstrumentation implements IDisposable {
  57764. /**
  57765. * Define the instrumented engine.
  57766. */
  57767. engine: Engine;
  57768. private _captureGPUFrameTime;
  57769. private _gpuFrameTimeToken;
  57770. private _gpuFrameTime;
  57771. private _captureShaderCompilationTime;
  57772. private _shaderCompilationTime;
  57773. private _onBeginFrameObserver;
  57774. private _onEndFrameObserver;
  57775. private _onBeforeShaderCompilationObserver;
  57776. private _onAfterShaderCompilationObserver;
  57777. /**
  57778. * Gets the perf counter used for GPU frame time
  57779. */
  57780. get gpuFrameTimeCounter(): PerfCounter;
  57781. /**
  57782. * Gets the GPU frame time capture status
  57783. */
  57784. get captureGPUFrameTime(): boolean;
  57785. /**
  57786. * Enable or disable the GPU frame time capture
  57787. */
  57788. set captureGPUFrameTime(value: boolean);
  57789. /**
  57790. * Gets the perf counter used for shader compilation time
  57791. */
  57792. get shaderCompilationTimeCounter(): PerfCounter;
  57793. /**
  57794. * Gets the shader compilation time capture status
  57795. */
  57796. get captureShaderCompilationTime(): boolean;
  57797. /**
  57798. * Enable or disable the shader compilation time capture
  57799. */
  57800. set captureShaderCompilationTime(value: boolean);
  57801. /**
  57802. * Instantiates a new engine instrumentation.
  57803. * This class can be used to get instrumentation data from a Babylon engine
  57804. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57805. * @param engine Defines the engine to instrument
  57806. */
  57807. constructor(
  57808. /**
  57809. * Define the instrumented engine.
  57810. */
  57811. engine: Engine);
  57812. /**
  57813. * Dispose and release associated resources.
  57814. */
  57815. dispose(): void;
  57816. }
  57817. }
  57818. declare module BABYLON {
  57819. /**
  57820. * This class can be used to get instrumentation data from a Babylon engine
  57821. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57822. */
  57823. export class SceneInstrumentation implements IDisposable {
  57824. /**
  57825. * Defines the scene to instrument
  57826. */
  57827. scene: Scene;
  57828. private _captureActiveMeshesEvaluationTime;
  57829. private _activeMeshesEvaluationTime;
  57830. private _captureRenderTargetsRenderTime;
  57831. private _renderTargetsRenderTime;
  57832. private _captureFrameTime;
  57833. private _frameTime;
  57834. private _captureRenderTime;
  57835. private _renderTime;
  57836. private _captureInterFrameTime;
  57837. private _interFrameTime;
  57838. private _captureParticlesRenderTime;
  57839. private _particlesRenderTime;
  57840. private _captureSpritesRenderTime;
  57841. private _spritesRenderTime;
  57842. private _capturePhysicsTime;
  57843. private _physicsTime;
  57844. private _captureAnimationsTime;
  57845. private _animationsTime;
  57846. private _captureCameraRenderTime;
  57847. private _cameraRenderTime;
  57848. private _onBeforeActiveMeshesEvaluationObserver;
  57849. private _onAfterActiveMeshesEvaluationObserver;
  57850. private _onBeforeRenderTargetsRenderObserver;
  57851. private _onAfterRenderTargetsRenderObserver;
  57852. private _onAfterRenderObserver;
  57853. private _onBeforeDrawPhaseObserver;
  57854. private _onAfterDrawPhaseObserver;
  57855. private _onBeforeAnimationsObserver;
  57856. private _onBeforeParticlesRenderingObserver;
  57857. private _onAfterParticlesRenderingObserver;
  57858. private _onBeforeSpritesRenderingObserver;
  57859. private _onAfterSpritesRenderingObserver;
  57860. private _onBeforePhysicsObserver;
  57861. private _onAfterPhysicsObserver;
  57862. private _onAfterAnimationsObserver;
  57863. private _onBeforeCameraRenderObserver;
  57864. private _onAfterCameraRenderObserver;
  57865. /**
  57866. * Gets the perf counter used for active meshes evaluation time
  57867. */
  57868. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57869. /**
  57870. * Gets the active meshes evaluation time capture status
  57871. */
  57872. get captureActiveMeshesEvaluationTime(): boolean;
  57873. /**
  57874. * Enable or disable the active meshes evaluation time capture
  57875. */
  57876. set captureActiveMeshesEvaluationTime(value: boolean);
  57877. /**
  57878. * Gets the perf counter used for render targets render time
  57879. */
  57880. get renderTargetsRenderTimeCounter(): PerfCounter;
  57881. /**
  57882. * Gets the render targets render time capture status
  57883. */
  57884. get captureRenderTargetsRenderTime(): boolean;
  57885. /**
  57886. * Enable or disable the render targets render time capture
  57887. */
  57888. set captureRenderTargetsRenderTime(value: boolean);
  57889. /**
  57890. * Gets the perf counter used for particles render time
  57891. */
  57892. get particlesRenderTimeCounter(): PerfCounter;
  57893. /**
  57894. * Gets the particles render time capture status
  57895. */
  57896. get captureParticlesRenderTime(): boolean;
  57897. /**
  57898. * Enable or disable the particles render time capture
  57899. */
  57900. set captureParticlesRenderTime(value: boolean);
  57901. /**
  57902. * Gets the perf counter used for sprites render time
  57903. */
  57904. get spritesRenderTimeCounter(): PerfCounter;
  57905. /**
  57906. * Gets the sprites render time capture status
  57907. */
  57908. get captureSpritesRenderTime(): boolean;
  57909. /**
  57910. * Enable or disable the sprites render time capture
  57911. */
  57912. set captureSpritesRenderTime(value: boolean);
  57913. /**
  57914. * Gets the perf counter used for physics time
  57915. */
  57916. get physicsTimeCounter(): PerfCounter;
  57917. /**
  57918. * Gets the physics time capture status
  57919. */
  57920. get capturePhysicsTime(): boolean;
  57921. /**
  57922. * Enable or disable the physics time capture
  57923. */
  57924. set capturePhysicsTime(value: boolean);
  57925. /**
  57926. * Gets the perf counter used for animations time
  57927. */
  57928. get animationsTimeCounter(): PerfCounter;
  57929. /**
  57930. * Gets the animations time capture status
  57931. */
  57932. get captureAnimationsTime(): boolean;
  57933. /**
  57934. * Enable or disable the animations time capture
  57935. */
  57936. set captureAnimationsTime(value: boolean);
  57937. /**
  57938. * Gets the perf counter used for frame time capture
  57939. */
  57940. get frameTimeCounter(): PerfCounter;
  57941. /**
  57942. * Gets the frame time capture status
  57943. */
  57944. get captureFrameTime(): boolean;
  57945. /**
  57946. * Enable or disable the frame time capture
  57947. */
  57948. set captureFrameTime(value: boolean);
  57949. /**
  57950. * Gets the perf counter used for inter-frames time capture
  57951. */
  57952. get interFrameTimeCounter(): PerfCounter;
  57953. /**
  57954. * Gets the inter-frames time capture status
  57955. */
  57956. get captureInterFrameTime(): boolean;
  57957. /**
  57958. * Enable or disable the inter-frames time capture
  57959. */
  57960. set captureInterFrameTime(value: boolean);
  57961. /**
  57962. * Gets the perf counter used for render time capture
  57963. */
  57964. get renderTimeCounter(): PerfCounter;
  57965. /**
  57966. * Gets the render time capture status
  57967. */
  57968. get captureRenderTime(): boolean;
  57969. /**
  57970. * Enable or disable the render time capture
  57971. */
  57972. set captureRenderTime(value: boolean);
  57973. /**
  57974. * Gets the perf counter used for camera render time capture
  57975. */
  57976. get cameraRenderTimeCounter(): PerfCounter;
  57977. /**
  57978. * Gets the camera render time capture status
  57979. */
  57980. get captureCameraRenderTime(): boolean;
  57981. /**
  57982. * Enable or disable the camera render time capture
  57983. */
  57984. set captureCameraRenderTime(value: boolean);
  57985. /**
  57986. * Gets the perf counter used for draw calls
  57987. */
  57988. get drawCallsCounter(): PerfCounter;
  57989. /**
  57990. * Instantiates a new scene instrumentation.
  57991. * This class can be used to get instrumentation data from a Babylon engine
  57992. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57993. * @param scene Defines the scene to instrument
  57994. */
  57995. constructor(
  57996. /**
  57997. * Defines the scene to instrument
  57998. */
  57999. scene: Scene);
  58000. /**
  58001. * Dispose and release associated resources.
  58002. */
  58003. dispose(): void;
  58004. }
  58005. }
  58006. declare module BABYLON {
  58007. /** @hidden */
  58008. export var glowMapGenerationPixelShader: {
  58009. name: string;
  58010. shader: string;
  58011. };
  58012. }
  58013. declare module BABYLON {
  58014. /** @hidden */
  58015. export var glowMapGenerationVertexShader: {
  58016. name: string;
  58017. shader: string;
  58018. };
  58019. }
  58020. declare module BABYLON {
  58021. /**
  58022. * Effect layer options. This helps customizing the behaviour
  58023. * of the effect layer.
  58024. */
  58025. export interface IEffectLayerOptions {
  58026. /**
  58027. * Multiplication factor apply to the canvas size to compute the render target size
  58028. * used to generated the objects (the smaller the faster).
  58029. */
  58030. mainTextureRatio: number;
  58031. /**
  58032. * Enforces a fixed size texture to ensure effect stability across devices.
  58033. */
  58034. mainTextureFixedSize?: number;
  58035. /**
  58036. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58037. */
  58038. alphaBlendingMode: number;
  58039. /**
  58040. * The camera attached to the layer.
  58041. */
  58042. camera: Nullable<Camera>;
  58043. /**
  58044. * The rendering group to draw the layer in.
  58045. */
  58046. renderingGroupId: number;
  58047. }
  58048. /**
  58049. * The effect layer Helps adding post process effect blended with the main pass.
  58050. *
  58051. * This can be for instance use to generate glow or higlight effects on the scene.
  58052. *
  58053. * The effect layer class can not be used directly and is intented to inherited from to be
  58054. * customized per effects.
  58055. */
  58056. export abstract class EffectLayer {
  58057. private _vertexBuffers;
  58058. private _indexBuffer;
  58059. private _cachedDefines;
  58060. private _effectLayerMapGenerationEffect;
  58061. private _effectLayerOptions;
  58062. private _mergeEffect;
  58063. protected _scene: Scene;
  58064. protected _engine: Engine;
  58065. protected _maxSize: number;
  58066. protected _mainTextureDesiredSize: ISize;
  58067. protected _mainTexture: RenderTargetTexture;
  58068. protected _shouldRender: boolean;
  58069. protected _postProcesses: PostProcess[];
  58070. protected _textures: BaseTexture[];
  58071. protected _emissiveTextureAndColor: {
  58072. texture: Nullable<BaseTexture>;
  58073. color: Color4;
  58074. };
  58075. /**
  58076. * The name of the layer
  58077. */
  58078. name: string;
  58079. /**
  58080. * The clear color of the texture used to generate the glow map.
  58081. */
  58082. neutralColor: Color4;
  58083. /**
  58084. * Specifies whether the highlight layer is enabled or not.
  58085. */
  58086. isEnabled: boolean;
  58087. /**
  58088. * Gets the camera attached to the layer.
  58089. */
  58090. get camera(): Nullable<Camera>;
  58091. /**
  58092. * Gets the rendering group id the layer should render in.
  58093. */
  58094. get renderingGroupId(): number;
  58095. set renderingGroupId(renderingGroupId: number);
  58096. /**
  58097. * An event triggered when the effect layer has been disposed.
  58098. */
  58099. onDisposeObservable: Observable<EffectLayer>;
  58100. /**
  58101. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58102. */
  58103. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58104. /**
  58105. * An event triggered when the generated texture is being merged in the scene.
  58106. */
  58107. onBeforeComposeObservable: Observable<EffectLayer>;
  58108. /**
  58109. * An event triggered when the mesh is rendered into the effect render target.
  58110. */
  58111. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58112. /**
  58113. * An event triggered after the mesh has been rendered into the effect render target.
  58114. */
  58115. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58116. /**
  58117. * An event triggered when the generated texture has been merged in the scene.
  58118. */
  58119. onAfterComposeObservable: Observable<EffectLayer>;
  58120. /**
  58121. * An event triggered when the efffect layer changes its size.
  58122. */
  58123. onSizeChangedObservable: Observable<EffectLayer>;
  58124. /** @hidden */
  58125. static _SceneComponentInitialization: (scene: Scene) => void;
  58126. /**
  58127. * Instantiates a new effect Layer and references it in the scene.
  58128. * @param name The name of the layer
  58129. * @param scene The scene to use the layer in
  58130. */
  58131. constructor(
  58132. /** The Friendly of the effect in the scene */
  58133. name: string, scene: Scene);
  58134. /**
  58135. * Get the effect name of the layer.
  58136. * @return The effect name
  58137. */
  58138. abstract getEffectName(): string;
  58139. /**
  58140. * Checks for the readiness of the element composing the layer.
  58141. * @param subMesh the mesh to check for
  58142. * @param useInstances specify whether or not to use instances to render the mesh
  58143. * @return true if ready otherwise, false
  58144. */
  58145. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58146. /**
  58147. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58148. * @returns true if the effect requires stencil during the main canvas render pass.
  58149. */
  58150. abstract needStencil(): boolean;
  58151. /**
  58152. * Create the merge effect. This is the shader use to blit the information back
  58153. * to the main canvas at the end of the scene rendering.
  58154. * @returns The effect containing the shader used to merge the effect on the main canvas
  58155. */
  58156. protected abstract _createMergeEffect(): Effect;
  58157. /**
  58158. * Creates the render target textures and post processes used in the effect layer.
  58159. */
  58160. protected abstract _createTextureAndPostProcesses(): void;
  58161. /**
  58162. * Implementation specific of rendering the generating effect on the main canvas.
  58163. * @param effect The effect used to render through
  58164. */
  58165. protected abstract _internalRender(effect: Effect): void;
  58166. /**
  58167. * Sets the required values for both the emissive texture and and the main color.
  58168. */
  58169. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58170. /**
  58171. * Free any resources and references associated to a mesh.
  58172. * Internal use
  58173. * @param mesh The mesh to free.
  58174. */
  58175. abstract _disposeMesh(mesh: Mesh): void;
  58176. /**
  58177. * Serializes this layer (Glow or Highlight for example)
  58178. * @returns a serialized layer object
  58179. */
  58180. abstract serialize?(): any;
  58181. /**
  58182. * Initializes the effect layer with the required options.
  58183. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58184. */
  58185. protected _init(options: Partial<IEffectLayerOptions>): void;
  58186. /**
  58187. * Generates the index buffer of the full screen quad blending to the main canvas.
  58188. */
  58189. private _generateIndexBuffer;
  58190. /**
  58191. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58192. */
  58193. private _generateVertexBuffer;
  58194. /**
  58195. * Sets the main texture desired size which is the closest power of two
  58196. * of the engine canvas size.
  58197. */
  58198. private _setMainTextureSize;
  58199. /**
  58200. * Creates the main texture for the effect layer.
  58201. */
  58202. protected _createMainTexture(): void;
  58203. /**
  58204. * Adds specific effects defines.
  58205. * @param defines The defines to add specifics to.
  58206. */
  58207. protected _addCustomEffectDefines(defines: string[]): void;
  58208. /**
  58209. * Checks for the readiness of the element composing the layer.
  58210. * @param subMesh the mesh to check for
  58211. * @param useInstances specify whether or not to use instances to render the mesh
  58212. * @param emissiveTexture the associated emissive texture used to generate the glow
  58213. * @return true if ready otherwise, false
  58214. */
  58215. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58216. /**
  58217. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58218. */
  58219. render(): void;
  58220. /**
  58221. * Determine if a given mesh will be used in the current effect.
  58222. * @param mesh mesh to test
  58223. * @returns true if the mesh will be used
  58224. */
  58225. hasMesh(mesh: AbstractMesh): boolean;
  58226. /**
  58227. * Returns true if the layer contains information to display, otherwise false.
  58228. * @returns true if the glow layer should be rendered
  58229. */
  58230. shouldRender(): boolean;
  58231. /**
  58232. * Returns true if the mesh should render, otherwise false.
  58233. * @param mesh The mesh to render
  58234. * @returns true if it should render otherwise false
  58235. */
  58236. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58237. /**
  58238. * Returns true if the mesh can be rendered, otherwise false.
  58239. * @param mesh The mesh to render
  58240. * @param material The material used on the mesh
  58241. * @returns true if it can be rendered otherwise false
  58242. */
  58243. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58244. /**
  58245. * Returns true if the mesh should render, otherwise false.
  58246. * @param mesh The mesh to render
  58247. * @returns true if it should render otherwise false
  58248. */
  58249. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58250. /**
  58251. * Renders the submesh passed in parameter to the generation map.
  58252. */
  58253. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58254. /**
  58255. * Defines whether the current material of the mesh should be use to render the effect.
  58256. * @param mesh defines the current mesh to render
  58257. */
  58258. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58259. /**
  58260. * Rebuild the required buffers.
  58261. * @hidden Internal use only.
  58262. */
  58263. _rebuild(): void;
  58264. /**
  58265. * Dispose only the render target textures and post process.
  58266. */
  58267. private _disposeTextureAndPostProcesses;
  58268. /**
  58269. * Dispose the highlight layer and free resources.
  58270. */
  58271. dispose(): void;
  58272. /**
  58273. * Gets the class name of the effect layer
  58274. * @returns the string with the class name of the effect layer
  58275. */
  58276. getClassName(): string;
  58277. /**
  58278. * Creates an effect layer from parsed effect layer data
  58279. * @param parsedEffectLayer defines effect layer data
  58280. * @param scene defines the current scene
  58281. * @param rootUrl defines the root URL containing the effect layer information
  58282. * @returns a parsed effect Layer
  58283. */
  58284. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58285. }
  58286. }
  58287. declare module BABYLON {
  58288. interface AbstractScene {
  58289. /**
  58290. * The list of effect layers (highlights/glow) added to the scene
  58291. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58292. * @see https://doc.babylonjs.com/how_to/glow_layer
  58293. */
  58294. effectLayers: Array<EffectLayer>;
  58295. /**
  58296. * Removes the given effect layer from this scene.
  58297. * @param toRemove defines the effect layer to remove
  58298. * @returns the index of the removed effect layer
  58299. */
  58300. removeEffectLayer(toRemove: EffectLayer): number;
  58301. /**
  58302. * Adds the given effect layer to this scene
  58303. * @param newEffectLayer defines the effect layer to add
  58304. */
  58305. addEffectLayer(newEffectLayer: EffectLayer): void;
  58306. }
  58307. /**
  58308. * Defines the layer scene component responsible to manage any effect layers
  58309. * in a given scene.
  58310. */
  58311. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58312. /**
  58313. * The component name helpfull to identify the component in the list of scene components.
  58314. */
  58315. readonly name: string;
  58316. /**
  58317. * The scene the component belongs to.
  58318. */
  58319. scene: Scene;
  58320. private _engine;
  58321. private _renderEffects;
  58322. private _needStencil;
  58323. private _previousStencilState;
  58324. /**
  58325. * Creates a new instance of the component for the given scene
  58326. * @param scene Defines the scene to register the component in
  58327. */
  58328. constructor(scene: Scene);
  58329. /**
  58330. * Registers the component in a given scene
  58331. */
  58332. register(): void;
  58333. /**
  58334. * Rebuilds the elements related to this component in case of
  58335. * context lost for instance.
  58336. */
  58337. rebuild(): void;
  58338. /**
  58339. * Serializes the component data to the specified json object
  58340. * @param serializationObject The object to serialize to
  58341. */
  58342. serialize(serializationObject: any): void;
  58343. /**
  58344. * Adds all the elements from the container to the scene
  58345. * @param container the container holding the elements
  58346. */
  58347. addFromContainer(container: AbstractScene): void;
  58348. /**
  58349. * Removes all the elements in the container from the scene
  58350. * @param container contains the elements to remove
  58351. * @param dispose if the removed element should be disposed (default: false)
  58352. */
  58353. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58354. /**
  58355. * Disposes the component and the associated ressources.
  58356. */
  58357. dispose(): void;
  58358. private _isReadyForMesh;
  58359. private _renderMainTexture;
  58360. private _setStencil;
  58361. private _setStencilBack;
  58362. private _draw;
  58363. private _drawCamera;
  58364. private _drawRenderingGroup;
  58365. }
  58366. }
  58367. declare module BABYLON {
  58368. /** @hidden */
  58369. export var glowMapMergePixelShader: {
  58370. name: string;
  58371. shader: string;
  58372. };
  58373. }
  58374. declare module BABYLON {
  58375. /** @hidden */
  58376. export var glowMapMergeVertexShader: {
  58377. name: string;
  58378. shader: string;
  58379. };
  58380. }
  58381. declare module BABYLON {
  58382. interface AbstractScene {
  58383. /**
  58384. * Return a the first highlight layer of the scene with a given name.
  58385. * @param name The name of the highlight layer to look for.
  58386. * @return The highlight layer if found otherwise null.
  58387. */
  58388. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58389. }
  58390. /**
  58391. * Glow layer options. This helps customizing the behaviour
  58392. * of the glow layer.
  58393. */
  58394. export interface IGlowLayerOptions {
  58395. /**
  58396. * Multiplication factor apply to the canvas size to compute the render target size
  58397. * used to generated the glowing objects (the smaller the faster).
  58398. */
  58399. mainTextureRatio: number;
  58400. /**
  58401. * Enforces a fixed size texture to ensure resize independant blur.
  58402. */
  58403. mainTextureFixedSize?: number;
  58404. /**
  58405. * How big is the kernel of the blur texture.
  58406. */
  58407. blurKernelSize: number;
  58408. /**
  58409. * The camera attached to the layer.
  58410. */
  58411. camera: Nullable<Camera>;
  58412. /**
  58413. * Enable MSAA by chosing the number of samples.
  58414. */
  58415. mainTextureSamples?: number;
  58416. /**
  58417. * The rendering group to draw the layer in.
  58418. */
  58419. renderingGroupId: number;
  58420. }
  58421. /**
  58422. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58423. *
  58424. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58425. *
  58426. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58427. */
  58428. export class GlowLayer extends EffectLayer {
  58429. /**
  58430. * Effect Name of the layer.
  58431. */
  58432. static readonly EffectName: string;
  58433. /**
  58434. * The default blur kernel size used for the glow.
  58435. */
  58436. static DefaultBlurKernelSize: number;
  58437. /**
  58438. * The default texture size ratio used for the glow.
  58439. */
  58440. static DefaultTextureRatio: number;
  58441. /**
  58442. * Sets the kernel size of the blur.
  58443. */
  58444. set blurKernelSize(value: number);
  58445. /**
  58446. * Gets the kernel size of the blur.
  58447. */
  58448. get blurKernelSize(): number;
  58449. /**
  58450. * Sets the glow intensity.
  58451. */
  58452. set intensity(value: number);
  58453. /**
  58454. * Gets the glow intensity.
  58455. */
  58456. get intensity(): number;
  58457. private _options;
  58458. private _intensity;
  58459. private _horizontalBlurPostprocess1;
  58460. private _verticalBlurPostprocess1;
  58461. private _horizontalBlurPostprocess2;
  58462. private _verticalBlurPostprocess2;
  58463. private _blurTexture1;
  58464. private _blurTexture2;
  58465. private _postProcesses1;
  58466. private _postProcesses2;
  58467. private _includedOnlyMeshes;
  58468. private _excludedMeshes;
  58469. private _meshesUsingTheirOwnMaterials;
  58470. /**
  58471. * Callback used to let the user override the color selection on a per mesh basis
  58472. */
  58473. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58474. /**
  58475. * Callback used to let the user override the texture selection on a per mesh basis
  58476. */
  58477. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58478. /**
  58479. * Instantiates a new glow Layer and references it to the scene.
  58480. * @param name The name of the layer
  58481. * @param scene The scene to use the layer in
  58482. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58483. */
  58484. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58485. /**
  58486. * Get the effect name of the layer.
  58487. * @return The effect name
  58488. */
  58489. getEffectName(): string;
  58490. /**
  58491. * Create the merge effect. This is the shader use to blit the information back
  58492. * to the main canvas at the end of the scene rendering.
  58493. */
  58494. protected _createMergeEffect(): Effect;
  58495. /**
  58496. * Creates the render target textures and post processes used in the glow layer.
  58497. */
  58498. protected _createTextureAndPostProcesses(): void;
  58499. /**
  58500. * Checks for the readiness of the element composing the layer.
  58501. * @param subMesh the mesh to check for
  58502. * @param useInstances specify wether or not to use instances to render the mesh
  58503. * @param emissiveTexture the associated emissive texture used to generate the glow
  58504. * @return true if ready otherwise, false
  58505. */
  58506. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58507. /**
  58508. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58509. */
  58510. needStencil(): boolean;
  58511. /**
  58512. * Returns true if the mesh can be rendered, otherwise false.
  58513. * @param mesh The mesh to render
  58514. * @param material The material used on the mesh
  58515. * @returns true if it can be rendered otherwise false
  58516. */
  58517. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58518. /**
  58519. * Implementation specific of rendering the generating effect on the main canvas.
  58520. * @param effect The effect used to render through
  58521. */
  58522. protected _internalRender(effect: Effect): void;
  58523. /**
  58524. * Sets the required values for both the emissive texture and and the main color.
  58525. */
  58526. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58527. /**
  58528. * Returns true if the mesh should render, otherwise false.
  58529. * @param mesh The mesh to render
  58530. * @returns true if it should render otherwise false
  58531. */
  58532. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58533. /**
  58534. * Adds specific effects defines.
  58535. * @param defines The defines to add specifics to.
  58536. */
  58537. protected _addCustomEffectDefines(defines: string[]): void;
  58538. /**
  58539. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58540. * @param mesh The mesh to exclude from the glow layer
  58541. */
  58542. addExcludedMesh(mesh: Mesh): void;
  58543. /**
  58544. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58545. * @param mesh The mesh to remove
  58546. */
  58547. removeExcludedMesh(mesh: Mesh): void;
  58548. /**
  58549. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58550. * @param mesh The mesh to include in the glow layer
  58551. */
  58552. addIncludedOnlyMesh(mesh: Mesh): void;
  58553. /**
  58554. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58555. * @param mesh The mesh to remove
  58556. */
  58557. removeIncludedOnlyMesh(mesh: Mesh): void;
  58558. /**
  58559. * Determine if a given mesh will be used in the glow layer
  58560. * @param mesh The mesh to test
  58561. * @returns true if the mesh will be highlighted by the current glow layer
  58562. */
  58563. hasMesh(mesh: AbstractMesh): boolean;
  58564. /**
  58565. * Defines whether the current material of the mesh should be use to render the effect.
  58566. * @param mesh defines the current mesh to render
  58567. */
  58568. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58569. /**
  58570. * Add a mesh to be rendered through its own material and not with emissive only.
  58571. * @param mesh The mesh for which we need to use its material
  58572. */
  58573. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58574. /**
  58575. * Remove a mesh from being rendered through its own material and not with emissive only.
  58576. * @param mesh The mesh for which we need to not use its material
  58577. */
  58578. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58579. /**
  58580. * Free any resources and references associated to a mesh.
  58581. * Internal use
  58582. * @param mesh The mesh to free.
  58583. * @hidden
  58584. */
  58585. _disposeMesh(mesh: Mesh): void;
  58586. /**
  58587. * Gets the class name of the effect layer
  58588. * @returns the string with the class name of the effect layer
  58589. */
  58590. getClassName(): string;
  58591. /**
  58592. * Serializes this glow layer
  58593. * @returns a serialized glow layer object
  58594. */
  58595. serialize(): any;
  58596. /**
  58597. * Creates a Glow Layer from parsed glow layer data
  58598. * @param parsedGlowLayer defines glow layer data
  58599. * @param scene defines the current scene
  58600. * @param rootUrl defines the root URL containing the glow layer information
  58601. * @returns a parsed Glow Layer
  58602. */
  58603. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58604. }
  58605. }
  58606. declare module BABYLON {
  58607. /** @hidden */
  58608. export var glowBlurPostProcessPixelShader: {
  58609. name: string;
  58610. shader: string;
  58611. };
  58612. }
  58613. declare module BABYLON {
  58614. interface AbstractScene {
  58615. /**
  58616. * Return a the first highlight layer of the scene with a given name.
  58617. * @param name The name of the highlight layer to look for.
  58618. * @return The highlight layer if found otherwise null.
  58619. */
  58620. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58621. }
  58622. /**
  58623. * Highlight layer options. This helps customizing the behaviour
  58624. * of the highlight layer.
  58625. */
  58626. export interface IHighlightLayerOptions {
  58627. /**
  58628. * Multiplication factor apply to the canvas size to compute the render target size
  58629. * used to generated the glowing objects (the smaller the faster).
  58630. */
  58631. mainTextureRatio: number;
  58632. /**
  58633. * Enforces a fixed size texture to ensure resize independant blur.
  58634. */
  58635. mainTextureFixedSize?: number;
  58636. /**
  58637. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58638. * of the picture to blur (the smaller the faster).
  58639. */
  58640. blurTextureSizeRatio: number;
  58641. /**
  58642. * How big in texel of the blur texture is the vertical blur.
  58643. */
  58644. blurVerticalSize: number;
  58645. /**
  58646. * How big in texel of the blur texture is the horizontal blur.
  58647. */
  58648. blurHorizontalSize: number;
  58649. /**
  58650. * Alpha blending mode used to apply the blur. Default is combine.
  58651. */
  58652. alphaBlendingMode: number;
  58653. /**
  58654. * The camera attached to the layer.
  58655. */
  58656. camera: Nullable<Camera>;
  58657. /**
  58658. * Should we display highlight as a solid stroke?
  58659. */
  58660. isStroke?: boolean;
  58661. /**
  58662. * The rendering group to draw the layer in.
  58663. */
  58664. renderingGroupId: number;
  58665. }
  58666. /**
  58667. * The highlight layer Helps adding a glow effect around a mesh.
  58668. *
  58669. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58670. * glowy meshes to your scene.
  58671. *
  58672. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58673. */
  58674. export class HighlightLayer extends EffectLayer {
  58675. name: string;
  58676. /**
  58677. * Effect Name of the highlight layer.
  58678. */
  58679. static readonly EffectName: string;
  58680. /**
  58681. * The neutral color used during the preparation of the glow effect.
  58682. * This is black by default as the blend operation is a blend operation.
  58683. */
  58684. static NeutralColor: Color4;
  58685. /**
  58686. * Stencil value used for glowing meshes.
  58687. */
  58688. static GlowingMeshStencilReference: number;
  58689. /**
  58690. * Stencil value used for the other meshes in the scene.
  58691. */
  58692. static NormalMeshStencilReference: number;
  58693. /**
  58694. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58695. */
  58696. innerGlow: boolean;
  58697. /**
  58698. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58699. */
  58700. outerGlow: boolean;
  58701. /**
  58702. * Specifies the horizontal size of the blur.
  58703. */
  58704. set blurHorizontalSize(value: number);
  58705. /**
  58706. * Specifies the vertical size of the blur.
  58707. */
  58708. set blurVerticalSize(value: number);
  58709. /**
  58710. * Gets the horizontal size of the blur.
  58711. */
  58712. get blurHorizontalSize(): number;
  58713. /**
  58714. * Gets the vertical size of the blur.
  58715. */
  58716. get blurVerticalSize(): number;
  58717. /**
  58718. * An event triggered when the highlight layer is being blurred.
  58719. */
  58720. onBeforeBlurObservable: Observable<HighlightLayer>;
  58721. /**
  58722. * An event triggered when the highlight layer has been blurred.
  58723. */
  58724. onAfterBlurObservable: Observable<HighlightLayer>;
  58725. private _instanceGlowingMeshStencilReference;
  58726. private _options;
  58727. private _downSamplePostprocess;
  58728. private _horizontalBlurPostprocess;
  58729. private _verticalBlurPostprocess;
  58730. private _blurTexture;
  58731. private _meshes;
  58732. private _excludedMeshes;
  58733. /**
  58734. * Instantiates a new highlight Layer and references it to the scene..
  58735. * @param name The name of the layer
  58736. * @param scene The scene to use the layer in
  58737. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58738. */
  58739. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58740. /**
  58741. * Get the effect name of the layer.
  58742. * @return The effect name
  58743. */
  58744. getEffectName(): string;
  58745. /**
  58746. * Create the merge effect. This is the shader use to blit the information back
  58747. * to the main canvas at the end of the scene rendering.
  58748. */
  58749. protected _createMergeEffect(): Effect;
  58750. /**
  58751. * Creates the render target textures and post processes used in the highlight layer.
  58752. */
  58753. protected _createTextureAndPostProcesses(): void;
  58754. /**
  58755. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58756. */
  58757. needStencil(): boolean;
  58758. /**
  58759. * Checks for the readiness of the element composing the layer.
  58760. * @param subMesh the mesh to check for
  58761. * @param useInstances specify wether or not to use instances to render the mesh
  58762. * @param emissiveTexture the associated emissive texture used to generate the glow
  58763. * @return true if ready otherwise, false
  58764. */
  58765. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58766. /**
  58767. * Implementation specific of rendering the generating effect on the main canvas.
  58768. * @param effect The effect used to render through
  58769. */
  58770. protected _internalRender(effect: Effect): void;
  58771. /**
  58772. * Returns true if the layer contains information to display, otherwise false.
  58773. */
  58774. shouldRender(): boolean;
  58775. /**
  58776. * Returns true if the mesh should render, otherwise false.
  58777. * @param mesh The mesh to render
  58778. * @returns true if it should render otherwise false
  58779. */
  58780. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58781. /**
  58782. * Returns true if the mesh can be rendered, otherwise false.
  58783. * @param mesh The mesh to render
  58784. * @param material The material used on the mesh
  58785. * @returns true if it can be rendered otherwise false
  58786. */
  58787. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58788. /**
  58789. * Adds specific effects defines.
  58790. * @param defines The defines to add specifics to.
  58791. */
  58792. protected _addCustomEffectDefines(defines: string[]): void;
  58793. /**
  58794. * Sets the required values for both the emissive texture and and the main color.
  58795. */
  58796. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58797. /**
  58798. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58799. * @param mesh The mesh to exclude from the highlight layer
  58800. */
  58801. addExcludedMesh(mesh: Mesh): void;
  58802. /**
  58803. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58804. * @param mesh The mesh to highlight
  58805. */
  58806. removeExcludedMesh(mesh: Mesh): void;
  58807. /**
  58808. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58809. * @param mesh mesh to test
  58810. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58811. */
  58812. hasMesh(mesh: AbstractMesh): boolean;
  58813. /**
  58814. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58815. * @param mesh The mesh to highlight
  58816. * @param color The color of the highlight
  58817. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58818. */
  58819. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58820. /**
  58821. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58822. * @param mesh The mesh to highlight
  58823. */
  58824. removeMesh(mesh: Mesh): void;
  58825. /**
  58826. * Remove all the meshes currently referenced in the highlight layer
  58827. */
  58828. removeAllMeshes(): void;
  58829. /**
  58830. * Force the stencil to the normal expected value for none glowing parts
  58831. */
  58832. private _defaultStencilReference;
  58833. /**
  58834. * Free any resources and references associated to a mesh.
  58835. * Internal use
  58836. * @param mesh The mesh to free.
  58837. * @hidden
  58838. */
  58839. _disposeMesh(mesh: Mesh): void;
  58840. /**
  58841. * Dispose the highlight layer and free resources.
  58842. */
  58843. dispose(): void;
  58844. /**
  58845. * Gets the class name of the effect layer
  58846. * @returns the string with the class name of the effect layer
  58847. */
  58848. getClassName(): string;
  58849. /**
  58850. * Serializes this Highlight layer
  58851. * @returns a serialized Highlight layer object
  58852. */
  58853. serialize(): any;
  58854. /**
  58855. * Creates a Highlight layer from parsed Highlight layer data
  58856. * @param parsedHightlightLayer defines the Highlight layer data
  58857. * @param scene defines the current scene
  58858. * @param rootUrl defines the root URL containing the Highlight layer information
  58859. * @returns a parsed Highlight layer
  58860. */
  58861. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58862. }
  58863. }
  58864. declare module BABYLON {
  58865. interface AbstractScene {
  58866. /**
  58867. * The list of layers (background and foreground) of the scene
  58868. */
  58869. layers: Array<Layer>;
  58870. }
  58871. /**
  58872. * Defines the layer scene component responsible to manage any layers
  58873. * in a given scene.
  58874. */
  58875. export class LayerSceneComponent implements ISceneComponent {
  58876. /**
  58877. * The component name helpfull to identify the component in the list of scene components.
  58878. */
  58879. readonly name: string;
  58880. /**
  58881. * The scene the component belongs to.
  58882. */
  58883. scene: Scene;
  58884. private _engine;
  58885. /**
  58886. * Creates a new instance of the component for the given scene
  58887. * @param scene Defines the scene to register the component in
  58888. */
  58889. constructor(scene: Scene);
  58890. /**
  58891. * Registers the component in a given scene
  58892. */
  58893. register(): void;
  58894. /**
  58895. * Rebuilds the elements related to this component in case of
  58896. * context lost for instance.
  58897. */
  58898. rebuild(): void;
  58899. /**
  58900. * Disposes the component and the associated ressources.
  58901. */
  58902. dispose(): void;
  58903. private _draw;
  58904. private _drawCameraPredicate;
  58905. private _drawCameraBackground;
  58906. private _drawCameraForeground;
  58907. private _drawRenderTargetPredicate;
  58908. private _drawRenderTargetBackground;
  58909. private _drawRenderTargetForeground;
  58910. /**
  58911. * Adds all the elements from the container to the scene
  58912. * @param container the container holding the elements
  58913. */
  58914. addFromContainer(container: AbstractScene): void;
  58915. /**
  58916. * Removes all the elements in the container from the scene
  58917. * @param container contains the elements to remove
  58918. * @param dispose if the removed element should be disposed (default: false)
  58919. */
  58920. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58921. }
  58922. }
  58923. declare module BABYLON {
  58924. /** @hidden */
  58925. export var layerPixelShader: {
  58926. name: string;
  58927. shader: string;
  58928. };
  58929. }
  58930. declare module BABYLON {
  58931. /** @hidden */
  58932. export var layerVertexShader: {
  58933. name: string;
  58934. shader: string;
  58935. };
  58936. }
  58937. declare module BABYLON {
  58938. /**
  58939. * This represents a full screen 2d layer.
  58940. * This can be useful to display a picture in the background of your scene for instance.
  58941. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58942. */
  58943. export class Layer {
  58944. /**
  58945. * Define the name of the layer.
  58946. */
  58947. name: string;
  58948. /**
  58949. * Define the texture the layer should display.
  58950. */
  58951. texture: Nullable<Texture>;
  58952. /**
  58953. * Is the layer in background or foreground.
  58954. */
  58955. isBackground: boolean;
  58956. /**
  58957. * Define the color of the layer (instead of texture).
  58958. */
  58959. color: Color4;
  58960. /**
  58961. * Define the scale of the layer in order to zoom in out of the texture.
  58962. */
  58963. scale: Vector2;
  58964. /**
  58965. * Define an offset for the layer in order to shift the texture.
  58966. */
  58967. offset: Vector2;
  58968. /**
  58969. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58970. */
  58971. alphaBlendingMode: number;
  58972. /**
  58973. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58974. * Alpha test will not mix with the background color in case of transparency.
  58975. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58976. */
  58977. alphaTest: boolean;
  58978. /**
  58979. * Define a mask to restrict the layer to only some of the scene cameras.
  58980. */
  58981. layerMask: number;
  58982. /**
  58983. * Define the list of render target the layer is visible into.
  58984. */
  58985. renderTargetTextures: RenderTargetTexture[];
  58986. /**
  58987. * Define if the layer is only used in renderTarget or if it also
  58988. * renders in the main frame buffer of the canvas.
  58989. */
  58990. renderOnlyInRenderTargetTextures: boolean;
  58991. private _scene;
  58992. private _vertexBuffers;
  58993. private _indexBuffer;
  58994. private _effect;
  58995. private _previousDefines;
  58996. /**
  58997. * An event triggered when the layer is disposed.
  58998. */
  58999. onDisposeObservable: Observable<Layer>;
  59000. private _onDisposeObserver;
  59001. /**
  59002. * Back compatibility with callback before the onDisposeObservable existed.
  59003. * The set callback will be triggered when the layer has been disposed.
  59004. */
  59005. set onDispose(callback: () => void);
  59006. /**
  59007. * An event triggered before rendering the scene
  59008. */
  59009. onBeforeRenderObservable: Observable<Layer>;
  59010. private _onBeforeRenderObserver;
  59011. /**
  59012. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59013. * The set callback will be triggered just before rendering the layer.
  59014. */
  59015. set onBeforeRender(callback: () => void);
  59016. /**
  59017. * An event triggered after rendering the scene
  59018. */
  59019. onAfterRenderObservable: Observable<Layer>;
  59020. private _onAfterRenderObserver;
  59021. /**
  59022. * Back compatibility with callback before the onAfterRenderObservable existed.
  59023. * The set callback will be triggered just after rendering the layer.
  59024. */
  59025. set onAfterRender(callback: () => void);
  59026. /**
  59027. * Instantiates a new layer.
  59028. * This represents a full screen 2d layer.
  59029. * This can be useful to display a picture in the background of your scene for instance.
  59030. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59031. * @param name Define the name of the layer in the scene
  59032. * @param imgUrl Define the url of the texture to display in the layer
  59033. * @param scene Define the scene the layer belongs to
  59034. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59035. * @param color Defines a color for the layer
  59036. */
  59037. constructor(
  59038. /**
  59039. * Define the name of the layer.
  59040. */
  59041. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59042. private _createIndexBuffer;
  59043. /** @hidden */
  59044. _rebuild(): void;
  59045. /**
  59046. * Renders the layer in the scene.
  59047. */
  59048. render(): void;
  59049. /**
  59050. * Disposes and releases the associated ressources.
  59051. */
  59052. dispose(): void;
  59053. }
  59054. }
  59055. declare module BABYLON {
  59056. /** @hidden */
  59057. export var lensFlarePixelShader: {
  59058. name: string;
  59059. shader: string;
  59060. };
  59061. }
  59062. declare module BABYLON {
  59063. /** @hidden */
  59064. export var lensFlareVertexShader: {
  59065. name: string;
  59066. shader: string;
  59067. };
  59068. }
  59069. declare module BABYLON {
  59070. /**
  59071. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59072. * It is usually composed of several `lensFlare`.
  59073. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59074. */
  59075. export class LensFlareSystem {
  59076. /**
  59077. * Define the name of the lens flare system
  59078. */
  59079. name: string;
  59080. /**
  59081. * List of lens flares used in this system.
  59082. */
  59083. lensFlares: LensFlare[];
  59084. /**
  59085. * Define a limit from the border the lens flare can be visible.
  59086. */
  59087. borderLimit: number;
  59088. /**
  59089. * Define a viewport border we do not want to see the lens flare in.
  59090. */
  59091. viewportBorder: number;
  59092. /**
  59093. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59094. */
  59095. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59096. /**
  59097. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59098. */
  59099. layerMask: number;
  59100. /**
  59101. * Define the id of the lens flare system in the scene.
  59102. * (equal to name by default)
  59103. */
  59104. id: string;
  59105. private _scene;
  59106. private _emitter;
  59107. private _vertexBuffers;
  59108. private _indexBuffer;
  59109. private _effect;
  59110. private _positionX;
  59111. private _positionY;
  59112. private _isEnabled;
  59113. /** @hidden */
  59114. static _SceneComponentInitialization: (scene: Scene) => void;
  59115. /**
  59116. * Instantiates a lens flare system.
  59117. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59118. * It is usually composed of several `lensFlare`.
  59119. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59120. * @param name Define the name of the lens flare system in the scene
  59121. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59122. * @param scene Define the scene the lens flare system belongs to
  59123. */
  59124. constructor(
  59125. /**
  59126. * Define the name of the lens flare system
  59127. */
  59128. name: string, emitter: any, scene: Scene);
  59129. /**
  59130. * Define if the lens flare system is enabled.
  59131. */
  59132. get isEnabled(): boolean;
  59133. set isEnabled(value: boolean);
  59134. /**
  59135. * Get the scene the effects belongs to.
  59136. * @returns the scene holding the lens flare system
  59137. */
  59138. getScene(): Scene;
  59139. /**
  59140. * Get the emitter of the lens flare system.
  59141. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59142. * @returns the emitter of the lens flare system
  59143. */
  59144. getEmitter(): any;
  59145. /**
  59146. * Set the emitter of the lens flare system.
  59147. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59148. * @param newEmitter Define the new emitter of the system
  59149. */
  59150. setEmitter(newEmitter: any): void;
  59151. /**
  59152. * Get the lens flare system emitter position.
  59153. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59154. * @returns the position
  59155. */
  59156. getEmitterPosition(): Vector3;
  59157. /**
  59158. * @hidden
  59159. */
  59160. computeEffectivePosition(globalViewport: Viewport): boolean;
  59161. /** @hidden */
  59162. _isVisible(): boolean;
  59163. /**
  59164. * @hidden
  59165. */
  59166. render(): boolean;
  59167. /**
  59168. * Dispose and release the lens flare with its associated resources.
  59169. */
  59170. dispose(): void;
  59171. /**
  59172. * Parse a lens flare system from a JSON repressentation
  59173. * @param parsedLensFlareSystem Define the JSON to parse
  59174. * @param scene Define the scene the parsed system should be instantiated in
  59175. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59176. * @returns the parsed system
  59177. */
  59178. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59179. /**
  59180. * Serialize the current Lens Flare System into a JSON representation.
  59181. * @returns the serialized JSON
  59182. */
  59183. serialize(): any;
  59184. }
  59185. }
  59186. declare module BABYLON {
  59187. /**
  59188. * This represents one of the lens effect in a `lensFlareSystem`.
  59189. * It controls one of the indiviual texture used in the effect.
  59190. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59191. */
  59192. export class LensFlare {
  59193. /**
  59194. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59195. */
  59196. size: number;
  59197. /**
  59198. * 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.
  59199. */
  59200. position: number;
  59201. /**
  59202. * Define the lens color.
  59203. */
  59204. color: Color3;
  59205. /**
  59206. * Define the lens texture.
  59207. */
  59208. texture: Nullable<Texture>;
  59209. /**
  59210. * Define the alpha mode to render this particular lens.
  59211. */
  59212. alphaMode: number;
  59213. private _system;
  59214. /**
  59215. * Creates a new Lens Flare.
  59216. * This represents one of the lens effect in a `lensFlareSystem`.
  59217. * It controls one of the indiviual texture used in the effect.
  59218. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59219. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59220. * @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.
  59221. * @param color Define the lens color
  59222. * @param imgUrl Define the lens texture url
  59223. * @param system Define the `lensFlareSystem` this flare is part of
  59224. * @returns The newly created Lens Flare
  59225. */
  59226. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59227. /**
  59228. * Instantiates a new Lens Flare.
  59229. * This represents one of the lens effect in a `lensFlareSystem`.
  59230. * It controls one of the indiviual texture used in the effect.
  59231. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59232. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59233. * @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.
  59234. * @param color Define the lens color
  59235. * @param imgUrl Define the lens texture url
  59236. * @param system Define the `lensFlareSystem` this flare is part of
  59237. */
  59238. constructor(
  59239. /**
  59240. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59241. */
  59242. size: number,
  59243. /**
  59244. * 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.
  59245. */
  59246. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59247. /**
  59248. * Dispose and release the lens flare with its associated resources.
  59249. */
  59250. dispose(): void;
  59251. }
  59252. }
  59253. declare module BABYLON {
  59254. interface AbstractScene {
  59255. /**
  59256. * The list of lens flare system added to the scene
  59257. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59258. */
  59259. lensFlareSystems: Array<LensFlareSystem>;
  59260. /**
  59261. * Removes the given lens flare system from this scene.
  59262. * @param toRemove The lens flare system to remove
  59263. * @returns The index of the removed lens flare system
  59264. */
  59265. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59266. /**
  59267. * Adds the given lens flare system to this scene
  59268. * @param newLensFlareSystem The lens flare system to add
  59269. */
  59270. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59271. /**
  59272. * Gets a lens flare system using its name
  59273. * @param name defines the name to look for
  59274. * @returns the lens flare system or null if not found
  59275. */
  59276. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59277. /**
  59278. * Gets a lens flare system using its id
  59279. * @param id defines the id to look for
  59280. * @returns the lens flare system or null if not found
  59281. */
  59282. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59283. }
  59284. /**
  59285. * Defines the lens flare scene component responsible to manage any lens flares
  59286. * in a given scene.
  59287. */
  59288. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59289. /**
  59290. * The component name helpfull to identify the component in the list of scene components.
  59291. */
  59292. readonly name: string;
  59293. /**
  59294. * The scene the component belongs to.
  59295. */
  59296. scene: Scene;
  59297. /**
  59298. * Creates a new instance of the component for the given scene
  59299. * @param scene Defines the scene to register the component in
  59300. */
  59301. constructor(scene: Scene);
  59302. /**
  59303. * Registers the component in a given scene
  59304. */
  59305. register(): void;
  59306. /**
  59307. * Rebuilds the elements related to this component in case of
  59308. * context lost for instance.
  59309. */
  59310. rebuild(): void;
  59311. /**
  59312. * Adds all the elements from the container to the scene
  59313. * @param container the container holding the elements
  59314. */
  59315. addFromContainer(container: AbstractScene): void;
  59316. /**
  59317. * Removes all the elements in the container from the scene
  59318. * @param container contains the elements to remove
  59319. * @param dispose if the removed element should be disposed (default: false)
  59320. */
  59321. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59322. /**
  59323. * Serializes the component data to the specified json object
  59324. * @param serializationObject The object to serialize to
  59325. */
  59326. serialize(serializationObject: any): void;
  59327. /**
  59328. * Disposes the component and the associated ressources.
  59329. */
  59330. dispose(): void;
  59331. private _draw;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. /** @hidden */
  59336. export var depthPixelShader: {
  59337. name: string;
  59338. shader: string;
  59339. };
  59340. }
  59341. declare module BABYLON {
  59342. /** @hidden */
  59343. export var depthVertexShader: {
  59344. name: string;
  59345. shader: string;
  59346. };
  59347. }
  59348. declare module BABYLON {
  59349. /**
  59350. * This represents a depth renderer in Babylon.
  59351. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59352. */
  59353. export class DepthRenderer {
  59354. private _scene;
  59355. private _depthMap;
  59356. private _effect;
  59357. private readonly _storeNonLinearDepth;
  59358. private readonly _clearColor;
  59359. /** Get if the depth renderer is using packed depth or not */
  59360. readonly isPacked: boolean;
  59361. private _cachedDefines;
  59362. private _camera;
  59363. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59364. enabled: boolean;
  59365. /**
  59366. * Specifiess that the depth renderer will only be used within
  59367. * the camera it is created for.
  59368. * This can help forcing its rendering during the camera processing.
  59369. */
  59370. useOnlyInActiveCamera: boolean;
  59371. /** @hidden */
  59372. static _SceneComponentInitialization: (scene: Scene) => void;
  59373. /**
  59374. * Instantiates a depth renderer
  59375. * @param scene The scene the renderer belongs to
  59376. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59377. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59378. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59379. */
  59380. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59381. /**
  59382. * Creates the depth rendering effect and checks if the effect is ready.
  59383. * @param subMesh The submesh to be used to render the depth map of
  59384. * @param useInstances If multiple world instances should be used
  59385. * @returns if the depth renderer is ready to render the depth map
  59386. */
  59387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59388. /**
  59389. * Gets the texture which the depth map will be written to.
  59390. * @returns The depth map texture
  59391. */
  59392. getDepthMap(): RenderTargetTexture;
  59393. /**
  59394. * Disposes of the depth renderer.
  59395. */
  59396. dispose(): void;
  59397. }
  59398. }
  59399. declare module BABYLON {
  59400. /** @hidden */
  59401. export var minmaxReduxPixelShader: {
  59402. name: string;
  59403. shader: string;
  59404. };
  59405. }
  59406. declare module BABYLON {
  59407. /**
  59408. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59409. * and maximum values from all values of the texture.
  59410. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59411. * The source values are read from the red channel of the texture.
  59412. */
  59413. export class MinMaxReducer {
  59414. /**
  59415. * Observable triggered when the computation has been performed
  59416. */
  59417. onAfterReductionPerformed: Observable<{
  59418. min: number;
  59419. max: number;
  59420. }>;
  59421. protected _camera: Camera;
  59422. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59423. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59424. protected _postProcessManager: PostProcessManager;
  59425. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59426. protected _forceFullscreenViewport: boolean;
  59427. /**
  59428. * Creates a min/max reducer
  59429. * @param camera The camera to use for the post processes
  59430. */
  59431. constructor(camera: Camera);
  59432. /**
  59433. * Gets the texture used to read the values from.
  59434. */
  59435. get sourceTexture(): Nullable<RenderTargetTexture>;
  59436. /**
  59437. * Sets the source texture to read the values from.
  59438. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59439. * because in such textures '1' value must not be taken into account to compute the maximum
  59440. * as this value is used to clear the texture.
  59441. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59442. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59443. * @param depthRedux Indicates if the texture is a depth texture or not
  59444. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59445. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59446. */
  59447. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59448. /**
  59449. * Defines the refresh rate of the computation.
  59450. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59451. */
  59452. get refreshRate(): number;
  59453. set refreshRate(value: number);
  59454. protected _activated: boolean;
  59455. /**
  59456. * Gets the activation status of the reducer
  59457. */
  59458. get activated(): boolean;
  59459. /**
  59460. * Activates the reduction computation.
  59461. * When activated, the observers registered in onAfterReductionPerformed are
  59462. * called after the compuation is performed
  59463. */
  59464. activate(): void;
  59465. /**
  59466. * Deactivates the reduction computation.
  59467. */
  59468. deactivate(): void;
  59469. /**
  59470. * Disposes the min/max reducer
  59471. * @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.
  59472. */
  59473. dispose(disposeAll?: boolean): void;
  59474. }
  59475. }
  59476. declare module BABYLON {
  59477. /**
  59478. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59479. */
  59480. export class DepthReducer extends MinMaxReducer {
  59481. private _depthRenderer;
  59482. private _depthRendererId;
  59483. /**
  59484. * Gets the depth renderer used for the computation.
  59485. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59486. */
  59487. get depthRenderer(): Nullable<DepthRenderer>;
  59488. /**
  59489. * Creates a depth reducer
  59490. * @param camera The camera used to render the depth texture
  59491. */
  59492. constructor(camera: Camera);
  59493. /**
  59494. * Sets the depth renderer to use to generate the depth map
  59495. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59496. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59497. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59498. */
  59499. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59500. /** @hidden */
  59501. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59502. /**
  59503. * Activates the reduction computation.
  59504. * When activated, the observers registered in onAfterReductionPerformed are
  59505. * called after the compuation is performed
  59506. */
  59507. activate(): void;
  59508. /**
  59509. * Deactivates the reduction computation.
  59510. */
  59511. deactivate(): void;
  59512. /**
  59513. * Disposes the depth reducer
  59514. * @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.
  59515. */
  59516. dispose(disposeAll?: boolean): void;
  59517. }
  59518. }
  59519. declare module BABYLON {
  59520. /**
  59521. * A CSM implementation allowing casting shadows on large scenes.
  59522. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59523. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59524. */
  59525. export class CascadedShadowGenerator extends ShadowGenerator {
  59526. private static readonly frustumCornersNDCSpace;
  59527. /**
  59528. * Name of the CSM class
  59529. */
  59530. static CLASSNAME: string;
  59531. /**
  59532. * Defines the default number of cascades used by the CSM.
  59533. */
  59534. static readonly DEFAULT_CASCADES_COUNT: number;
  59535. /**
  59536. * Defines the minimum number of cascades used by the CSM.
  59537. */
  59538. static readonly MIN_CASCADES_COUNT: number;
  59539. /**
  59540. * Defines the maximum number of cascades used by the CSM.
  59541. */
  59542. static readonly MAX_CASCADES_COUNT: number;
  59543. protected _validateFilter(filter: number): number;
  59544. /**
  59545. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59546. */
  59547. penumbraDarkness: number;
  59548. private _numCascades;
  59549. /**
  59550. * Gets or set the number of cascades used by the CSM.
  59551. */
  59552. get numCascades(): number;
  59553. set numCascades(value: number);
  59554. /**
  59555. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59556. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59557. */
  59558. stabilizeCascades: boolean;
  59559. private _freezeShadowCastersBoundingInfo;
  59560. private _freezeShadowCastersBoundingInfoObservable;
  59561. /**
  59562. * Enables or disables the shadow casters bounding info computation.
  59563. * If your shadow casters don't move, you can disable this feature.
  59564. * If it is enabled, the bounding box computation is done every frame.
  59565. */
  59566. get freezeShadowCastersBoundingInfo(): boolean;
  59567. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59568. private _scbiMin;
  59569. private _scbiMax;
  59570. protected _computeShadowCastersBoundingInfo(): void;
  59571. protected _shadowCastersBoundingInfo: BoundingInfo;
  59572. /**
  59573. * Gets or sets the shadow casters bounding info.
  59574. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59575. * so that the system won't overwrite the bounds you provide
  59576. */
  59577. get shadowCastersBoundingInfo(): BoundingInfo;
  59578. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59579. protected _breaksAreDirty: boolean;
  59580. protected _minDistance: number;
  59581. protected _maxDistance: number;
  59582. /**
  59583. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59584. *
  59585. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59586. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59587. * @param min minimal distance for the breaks (default to 0.)
  59588. * @param max maximal distance for the breaks (default to 1.)
  59589. */
  59590. setMinMaxDistance(min: number, max: number): void;
  59591. /** Gets the minimal distance used in the cascade break computation */
  59592. get minDistance(): number;
  59593. /** Gets the maximal distance used in the cascade break computation */
  59594. get maxDistance(): number;
  59595. /**
  59596. * Gets the class name of that object
  59597. * @returns "CascadedShadowGenerator"
  59598. */
  59599. getClassName(): string;
  59600. private _cascadeMinExtents;
  59601. private _cascadeMaxExtents;
  59602. /**
  59603. * Gets a cascade minimum extents
  59604. * @param cascadeIndex index of the cascade
  59605. * @returns the minimum cascade extents
  59606. */
  59607. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59608. /**
  59609. * Gets a cascade maximum extents
  59610. * @param cascadeIndex index of the cascade
  59611. * @returns the maximum cascade extents
  59612. */
  59613. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59614. private _cascades;
  59615. private _currentLayer;
  59616. private _viewSpaceFrustumsZ;
  59617. private _viewMatrices;
  59618. private _projectionMatrices;
  59619. private _transformMatrices;
  59620. private _transformMatricesAsArray;
  59621. private _frustumLengths;
  59622. private _lightSizeUVCorrection;
  59623. private _depthCorrection;
  59624. private _frustumCornersWorldSpace;
  59625. private _frustumCenter;
  59626. private _shadowCameraPos;
  59627. private _shadowMaxZ;
  59628. /**
  59629. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59630. * It defaults to camera.maxZ
  59631. */
  59632. get shadowMaxZ(): number;
  59633. /**
  59634. * Sets the shadow max z distance.
  59635. */
  59636. set shadowMaxZ(value: number);
  59637. protected _debug: boolean;
  59638. /**
  59639. * Gets or sets the debug flag.
  59640. * When enabled, the cascades are materialized by different colors on the screen.
  59641. */
  59642. get debug(): boolean;
  59643. set debug(dbg: boolean);
  59644. private _depthClamp;
  59645. /**
  59646. * Gets or sets the depth clamping value.
  59647. *
  59648. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59649. * to account for the shadow casters far away.
  59650. *
  59651. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59652. */
  59653. get depthClamp(): boolean;
  59654. set depthClamp(value: boolean);
  59655. private _cascadeBlendPercentage;
  59656. /**
  59657. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59658. * It defaults to 0.1 (10% blending).
  59659. */
  59660. get cascadeBlendPercentage(): number;
  59661. set cascadeBlendPercentage(value: number);
  59662. private _lambda;
  59663. /**
  59664. * Gets or set the lambda parameter.
  59665. * This parameter is used to split the camera frustum and create the cascades.
  59666. * 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.
  59667. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59668. */
  59669. get lambda(): number;
  59670. set lambda(value: number);
  59671. /**
  59672. * Gets the view matrix corresponding to a given cascade
  59673. * @param cascadeNum cascade to retrieve the view matrix from
  59674. * @returns the cascade view matrix
  59675. */
  59676. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59677. /**
  59678. * Gets the projection matrix corresponding to a given cascade
  59679. * @param cascadeNum cascade to retrieve the projection matrix from
  59680. * @returns the cascade projection matrix
  59681. */
  59682. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59683. /**
  59684. * Gets the transformation matrix corresponding to a given cascade
  59685. * @param cascadeNum cascade to retrieve the transformation matrix from
  59686. * @returns the cascade transformation matrix
  59687. */
  59688. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59689. private _depthRenderer;
  59690. /**
  59691. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59692. *
  59693. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59694. *
  59695. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59696. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59697. * @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
  59698. */
  59699. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59700. private _depthReducer;
  59701. private _autoCalcDepthBounds;
  59702. /**
  59703. * Gets or sets the autoCalcDepthBounds property.
  59704. *
  59705. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59706. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59707. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59708. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59709. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59710. */
  59711. get autoCalcDepthBounds(): boolean;
  59712. set autoCalcDepthBounds(value: boolean);
  59713. /**
  59714. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59715. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59716. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59717. * for setting the refresh rate on the renderer yourself!
  59718. */
  59719. get autoCalcDepthBoundsRefreshRate(): number;
  59720. set autoCalcDepthBoundsRefreshRate(value: number);
  59721. /**
  59722. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59723. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59724. * you change the camera near/far planes!
  59725. */
  59726. splitFrustum(): void;
  59727. private _splitFrustum;
  59728. private _computeMatrices;
  59729. private _computeFrustumInWorldSpace;
  59730. private _computeCascadeFrustum;
  59731. /**
  59732. * Support test.
  59733. */
  59734. static get IsSupported(): boolean;
  59735. /** @hidden */
  59736. static _SceneComponentInitialization: (scene: Scene) => void;
  59737. /**
  59738. * Creates a Cascaded Shadow Generator object.
  59739. * A ShadowGenerator is the required tool to use the shadows.
  59740. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59741. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59742. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59743. * @param light The directional light object generating the shadows.
  59744. * @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.
  59745. */
  59746. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59747. protected _initializeGenerator(): void;
  59748. protected _createTargetRenderTexture(): void;
  59749. protected _initializeShadowMap(): void;
  59750. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59751. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59752. /**
  59753. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59754. * @param defines Defines of the material we want to update
  59755. * @param lightIndex Index of the light in the enabled light list of the material
  59756. */
  59757. prepareDefines(defines: any, lightIndex: number): void;
  59758. /**
  59759. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59760. * defined in the generator but impacting the effect).
  59761. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59762. * @param effect The effect we are binfing the information for
  59763. */
  59764. bindShadowLight(lightIndex: string, effect: Effect): void;
  59765. /**
  59766. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59767. * (eq to view projection * shadow projection matrices)
  59768. * @returns The transform matrix used to create the shadow map
  59769. */
  59770. getTransformMatrix(): Matrix;
  59771. /**
  59772. * Disposes the ShadowGenerator.
  59773. * Returns nothing.
  59774. */
  59775. dispose(): void;
  59776. /**
  59777. * Serializes the shadow generator setup to a json object.
  59778. * @returns The serialized JSON object
  59779. */
  59780. serialize(): any;
  59781. /**
  59782. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59783. * @param parsedShadowGenerator The JSON object to parse
  59784. * @param scene The scene to create the shadow map for
  59785. * @returns The parsed shadow generator
  59786. */
  59787. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59788. }
  59789. }
  59790. declare module BABYLON {
  59791. /**
  59792. * Defines the shadow generator component responsible to manage any shadow generators
  59793. * in a given scene.
  59794. */
  59795. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59796. /**
  59797. * The component name helpfull to identify the component in the list of scene components.
  59798. */
  59799. readonly name: string;
  59800. /**
  59801. * The scene the component belongs to.
  59802. */
  59803. scene: Scene;
  59804. /**
  59805. * Creates a new instance of the component for the given scene
  59806. * @param scene Defines the scene to register the component in
  59807. */
  59808. constructor(scene: Scene);
  59809. /**
  59810. * Registers the component in a given scene
  59811. */
  59812. register(): void;
  59813. /**
  59814. * Rebuilds the elements related to this component in case of
  59815. * context lost for instance.
  59816. */
  59817. rebuild(): void;
  59818. /**
  59819. * Serializes the component data to the specified json object
  59820. * @param serializationObject The object to serialize to
  59821. */
  59822. serialize(serializationObject: any): void;
  59823. /**
  59824. * Adds all the elements from the container to the scene
  59825. * @param container the container holding the elements
  59826. */
  59827. addFromContainer(container: AbstractScene): void;
  59828. /**
  59829. * Removes all the elements in the container from the scene
  59830. * @param container contains the elements to remove
  59831. * @param dispose if the removed element should be disposed (default: false)
  59832. */
  59833. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59834. /**
  59835. * Rebuilds the elements related to this component in case of
  59836. * context lost for instance.
  59837. */
  59838. dispose(): void;
  59839. private _gatherRenderTargets;
  59840. }
  59841. }
  59842. declare module BABYLON {
  59843. /**
  59844. * A point light is a light defined by an unique point in world space.
  59845. * The light is emitted in every direction from this point.
  59846. * A good example of a point light is a standard light bulb.
  59847. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59848. */
  59849. export class PointLight extends ShadowLight {
  59850. private _shadowAngle;
  59851. /**
  59852. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59853. * This specifies what angle the shadow will use to be created.
  59854. *
  59855. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59856. */
  59857. get shadowAngle(): number;
  59858. /**
  59859. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59860. * This specifies what angle the shadow will use to be created.
  59861. *
  59862. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59863. */
  59864. set shadowAngle(value: number);
  59865. /**
  59866. * Gets the direction if it has been set.
  59867. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59868. */
  59869. get direction(): Vector3;
  59870. /**
  59871. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59872. */
  59873. set direction(value: Vector3);
  59874. /**
  59875. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59876. * A PointLight emits the light in every direction.
  59877. * It can cast shadows.
  59878. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59879. * ```javascript
  59880. * var pointLight = new PointLight("pl", camera.position, scene);
  59881. * ```
  59882. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59883. * @param name The light friendly name
  59884. * @param position The position of the point light in the scene
  59885. * @param scene The scene the lights belongs to
  59886. */
  59887. constructor(name: string, position: Vector3, scene: Scene);
  59888. /**
  59889. * Returns the string "PointLight"
  59890. * @returns the class name
  59891. */
  59892. getClassName(): string;
  59893. /**
  59894. * Returns the integer 0.
  59895. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59896. */
  59897. getTypeID(): number;
  59898. /**
  59899. * Specifies wether or not the shadowmap should be a cube texture.
  59900. * @returns true if the shadowmap needs to be a cube texture.
  59901. */
  59902. needCube(): boolean;
  59903. /**
  59904. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59905. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59906. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59907. */
  59908. getShadowDirection(faceIndex?: number): Vector3;
  59909. /**
  59910. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59911. * - fov = PI / 2
  59912. * - aspect ratio : 1.0
  59913. * - z-near and far equal to the active camera minZ and maxZ.
  59914. * Returns the PointLight.
  59915. */
  59916. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59917. protected _buildUniformLayout(): void;
  59918. /**
  59919. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59920. * @param effect The effect to update
  59921. * @param lightIndex The index of the light in the effect to update
  59922. * @returns The point light
  59923. */
  59924. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59925. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59926. /**
  59927. * Prepares the list of defines specific to the light type.
  59928. * @param defines the list of defines
  59929. * @param lightIndex defines the index of the light for the effect
  59930. */
  59931. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /**
  59936. * Header information of HDR texture files.
  59937. */
  59938. export interface HDRInfo {
  59939. /**
  59940. * The height of the texture in pixels.
  59941. */
  59942. height: number;
  59943. /**
  59944. * The width of the texture in pixels.
  59945. */
  59946. width: number;
  59947. /**
  59948. * The index of the beginning of the data in the binary file.
  59949. */
  59950. dataPosition: number;
  59951. }
  59952. /**
  59953. * This groups tools to convert HDR texture to native colors array.
  59954. */
  59955. export class HDRTools {
  59956. private static Ldexp;
  59957. private static Rgbe2float;
  59958. private static readStringLine;
  59959. /**
  59960. * Reads header information from an RGBE texture stored in a native array.
  59961. * More information on this format are available here:
  59962. * https://en.wikipedia.org/wiki/RGBE_image_format
  59963. *
  59964. * @param uint8array The binary file stored in native array.
  59965. * @return The header information.
  59966. */
  59967. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59968. /**
  59969. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59970. * This RGBE texture needs to store the information as a panorama.
  59971. *
  59972. * More information on this format are available here:
  59973. * https://en.wikipedia.org/wiki/RGBE_image_format
  59974. *
  59975. * @param buffer The binary file stored in an array buffer.
  59976. * @param size The expected size of the extracted cubemap.
  59977. * @return The Cube Map information.
  59978. */
  59979. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59980. /**
  59981. * Returns the pixels data extracted from an RGBE texture.
  59982. * This pixels will be stored left to right up to down in the R G B order in one array.
  59983. *
  59984. * More information on this format are available here:
  59985. * https://en.wikipedia.org/wiki/RGBE_image_format
  59986. *
  59987. * @param uint8array The binary file stored in an array buffer.
  59988. * @param hdrInfo The header information of the file.
  59989. * @return The pixels data in RGB right to left up to down order.
  59990. */
  59991. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59992. private static RGBE_ReadPixels_RLE;
  59993. private static RGBE_ReadPixels_NOT_RLE;
  59994. }
  59995. }
  59996. declare module BABYLON {
  59997. /**
  59998. * Effect Render Options
  59999. */
  60000. export interface IEffectRendererOptions {
  60001. /**
  60002. * Defines the vertices positions.
  60003. */
  60004. positions?: number[];
  60005. /**
  60006. * Defines the indices.
  60007. */
  60008. indices?: number[];
  60009. }
  60010. /**
  60011. * Helper class to render one or more effects.
  60012. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60013. */
  60014. export class EffectRenderer {
  60015. private engine;
  60016. private static _DefaultOptions;
  60017. private _vertexBuffers;
  60018. private _indexBuffer;
  60019. private _fullscreenViewport;
  60020. /**
  60021. * Creates an effect renderer
  60022. * @param engine the engine to use for rendering
  60023. * @param options defines the options of the effect renderer
  60024. */
  60025. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60026. /**
  60027. * Sets the current viewport in normalized coordinates 0-1
  60028. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60029. */
  60030. setViewport(viewport?: Viewport): void;
  60031. /**
  60032. * Binds the embedded attributes buffer to the effect.
  60033. * @param effect Defines the effect to bind the attributes for
  60034. */
  60035. bindBuffers(effect: Effect): void;
  60036. /**
  60037. * Sets the current effect wrapper to use during draw.
  60038. * The effect needs to be ready before calling this api.
  60039. * This also sets the default full screen position attribute.
  60040. * @param effectWrapper Defines the effect to draw with
  60041. */
  60042. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60043. /**
  60044. * Restores engine states
  60045. */
  60046. restoreStates(): void;
  60047. /**
  60048. * Draws a full screen quad.
  60049. */
  60050. draw(): void;
  60051. private isRenderTargetTexture;
  60052. /**
  60053. * renders one or more effects to a specified texture
  60054. * @param effectWrapper the effect to renderer
  60055. * @param outputTexture texture to draw to, if null it will render to the screen.
  60056. */
  60057. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60058. /**
  60059. * Disposes of the effect renderer
  60060. */
  60061. dispose(): void;
  60062. }
  60063. /**
  60064. * Options to create an EffectWrapper
  60065. */
  60066. interface EffectWrapperCreationOptions {
  60067. /**
  60068. * Engine to use to create the effect
  60069. */
  60070. engine: ThinEngine;
  60071. /**
  60072. * Fragment shader for the effect
  60073. */
  60074. fragmentShader: string;
  60075. /**
  60076. * Use the shader store instead of direct source code
  60077. */
  60078. useShaderStore?: boolean;
  60079. /**
  60080. * Vertex shader for the effect
  60081. */
  60082. vertexShader?: string;
  60083. /**
  60084. * Attributes to use in the shader
  60085. */
  60086. attributeNames?: Array<string>;
  60087. /**
  60088. * Uniforms to use in the shader
  60089. */
  60090. uniformNames?: Array<string>;
  60091. /**
  60092. * Texture sampler names to use in the shader
  60093. */
  60094. samplerNames?: Array<string>;
  60095. /**
  60096. * Defines to use in the shader
  60097. */
  60098. defines?: Array<string>;
  60099. /**
  60100. * Callback when effect is compiled
  60101. */
  60102. onCompiled?: Nullable<(effect: Effect) => void>;
  60103. /**
  60104. * The friendly name of the effect displayed in Spector.
  60105. */
  60106. name?: string;
  60107. }
  60108. /**
  60109. * Wraps an effect to be used for rendering
  60110. */
  60111. export class EffectWrapper {
  60112. /**
  60113. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60114. */
  60115. onApplyObservable: Observable<{}>;
  60116. /**
  60117. * The underlying effect
  60118. */
  60119. effect: Effect;
  60120. /**
  60121. * Creates an effect to be renderer
  60122. * @param creationOptions options to create the effect
  60123. */
  60124. constructor(creationOptions: EffectWrapperCreationOptions);
  60125. /**
  60126. * Disposes of the effect wrapper
  60127. */
  60128. dispose(): void;
  60129. }
  60130. }
  60131. declare module BABYLON {
  60132. /** @hidden */
  60133. export var hdrFilteringVertexShader: {
  60134. name: string;
  60135. shader: string;
  60136. };
  60137. }
  60138. declare module BABYLON {
  60139. /** @hidden */
  60140. export var hdrFilteringPixelShader: {
  60141. name: string;
  60142. shader: string;
  60143. };
  60144. }
  60145. declare module BABYLON {
  60146. /**
  60147. * Options for texture filtering
  60148. */
  60149. interface IHDRFilteringOptions {
  60150. /**
  60151. * Scales pixel intensity for the input HDR map.
  60152. */
  60153. hdrScale?: number;
  60154. /**
  60155. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60156. */
  60157. quality?: number;
  60158. }
  60159. /**
  60160. * Filters HDR maps to get correct renderings of PBR reflections
  60161. */
  60162. export class HDRFiltering {
  60163. private _engine;
  60164. private _effectRenderer;
  60165. private _effectWrapper;
  60166. private _lodGenerationOffset;
  60167. private _lodGenerationScale;
  60168. /**
  60169. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60170. * you care about baking speed.
  60171. */
  60172. quality: number;
  60173. /**
  60174. * Scales pixel intensity for the input HDR map.
  60175. */
  60176. hdrScale: number;
  60177. /**
  60178. * Instantiates HDR filter for reflection maps
  60179. *
  60180. * @param engine Thin engine
  60181. * @param options Options
  60182. */
  60183. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60184. private _createRenderTarget;
  60185. private _prefilterInternal;
  60186. private _createEffect;
  60187. /**
  60188. * Get a value indicating if the filter is ready to be used
  60189. * @param texture Texture to filter
  60190. * @returns true if the filter is ready
  60191. */
  60192. isReady(texture: BaseTexture): boolean;
  60193. /**
  60194. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60195. * Prefiltering will be invoked at the end of next rendering pass.
  60196. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60197. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60198. * @param texture Texture to filter
  60199. * @param onFinished Callback when filtering is done
  60200. * @return Promise called when prefiltering is done
  60201. */
  60202. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60203. }
  60204. }
  60205. declare module BABYLON {
  60206. /**
  60207. * This represents a texture coming from an HDR input.
  60208. *
  60209. * The only supported format is currently panorama picture stored in RGBE format.
  60210. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60211. */
  60212. export class HDRCubeTexture extends BaseTexture {
  60213. private static _facesMapping;
  60214. private _generateHarmonics;
  60215. private _noMipmap;
  60216. private _prefilterOnLoad;
  60217. private _textureMatrix;
  60218. private _size;
  60219. private _onLoad;
  60220. private _onError;
  60221. /**
  60222. * The texture URL.
  60223. */
  60224. url: string;
  60225. /**
  60226. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  60227. */
  60228. coordinatesMode: number;
  60229. protected _isBlocking: boolean;
  60230. /**
  60231. * Sets wether or not the texture is blocking during loading.
  60232. */
  60233. set isBlocking(value: boolean);
  60234. /**
  60235. * Gets wether or not the texture is blocking during loading.
  60236. */
  60237. get isBlocking(): boolean;
  60238. protected _rotationY: number;
  60239. /**
  60240. * Sets texture matrix rotation angle around Y axis in radians.
  60241. */
  60242. set rotationY(value: number);
  60243. /**
  60244. * Gets texture matrix rotation angle around Y axis radians.
  60245. */
  60246. get rotationY(): number;
  60247. /**
  60248. * Gets or sets the center of the bounding box associated with the cube texture
  60249. * It must define where the camera used to render the texture was set
  60250. */
  60251. boundingBoxPosition: Vector3;
  60252. private _boundingBoxSize;
  60253. /**
  60254. * Gets or sets the size of the bounding box associated with the cube texture
  60255. * When defined, the cubemap will switch to local mode
  60256. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60257. * @example https://www.babylonjs-playground.com/#RNASML
  60258. */
  60259. set boundingBoxSize(value: Vector3);
  60260. get boundingBoxSize(): Vector3;
  60261. /**
  60262. * Instantiates an HDRTexture from the following parameters.
  60263. *
  60264. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60265. * @param sceneOrEngine The scene or engine the texture will be used in
  60266. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60267. * @param noMipmap Forces to not generate the mipmap if true
  60268. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60269. * @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)
  60270. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60271. */
  60272. 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>);
  60273. /**
  60274. * Get the current class name of the texture useful for serialization or dynamic coding.
  60275. * @returns "HDRCubeTexture"
  60276. */
  60277. getClassName(): string;
  60278. /**
  60279. * Occurs when the file is raw .hdr file.
  60280. */
  60281. private loadTexture;
  60282. clone(): HDRCubeTexture;
  60283. delayLoad(): void;
  60284. /**
  60285. * Get the texture reflection matrix used to rotate/transform the reflection.
  60286. * @returns the reflection matrix
  60287. */
  60288. getReflectionTextureMatrix(): Matrix;
  60289. /**
  60290. * Set the texture reflection matrix used to rotate/transform the reflection.
  60291. * @param value Define the reflection matrix to set
  60292. */
  60293. setReflectionTextureMatrix(value: Matrix): void;
  60294. /**
  60295. * Parses a JSON representation of an HDR Texture in order to create the texture
  60296. * @param parsedTexture Define the JSON representation
  60297. * @param scene Define the scene the texture should be created in
  60298. * @param rootUrl Define the root url in case we need to load relative dependencies
  60299. * @returns the newly created texture after parsing
  60300. */
  60301. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60302. serialize(): any;
  60303. }
  60304. }
  60305. declare module BABYLON {
  60306. /**
  60307. * Class used to control physics engine
  60308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60309. */
  60310. export class PhysicsEngine implements IPhysicsEngine {
  60311. private _physicsPlugin;
  60312. /**
  60313. * Global value used to control the smallest number supported by the simulation
  60314. */
  60315. static Epsilon: number;
  60316. private _impostors;
  60317. private _joints;
  60318. private _subTimeStep;
  60319. /**
  60320. * Gets the gravity vector used by the simulation
  60321. */
  60322. gravity: Vector3;
  60323. /**
  60324. * Factory used to create the default physics plugin.
  60325. * @returns The default physics plugin
  60326. */
  60327. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60328. /**
  60329. * Creates a new Physics Engine
  60330. * @param gravity defines the gravity vector used by the simulation
  60331. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60332. */
  60333. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60334. /**
  60335. * Sets the gravity vector used by the simulation
  60336. * @param gravity defines the gravity vector to use
  60337. */
  60338. setGravity(gravity: Vector3): void;
  60339. /**
  60340. * Set the time step of the physics engine.
  60341. * Default is 1/60.
  60342. * To slow it down, enter 1/600 for example.
  60343. * To speed it up, 1/30
  60344. * @param newTimeStep defines the new timestep to apply to this world.
  60345. */
  60346. setTimeStep(newTimeStep?: number): void;
  60347. /**
  60348. * Get the time step of the physics engine.
  60349. * @returns the current time step
  60350. */
  60351. getTimeStep(): number;
  60352. /**
  60353. * Set the sub time step of the physics engine.
  60354. * Default is 0 meaning there is no sub steps
  60355. * To increase physics resolution precision, set a small value (like 1 ms)
  60356. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60357. */
  60358. setSubTimeStep(subTimeStep?: number): void;
  60359. /**
  60360. * Get the sub time step of the physics engine.
  60361. * @returns the current sub time step
  60362. */
  60363. getSubTimeStep(): number;
  60364. /**
  60365. * Release all resources
  60366. */
  60367. dispose(): void;
  60368. /**
  60369. * Gets the name of the current physics plugin
  60370. * @returns the name of the plugin
  60371. */
  60372. getPhysicsPluginName(): string;
  60373. /**
  60374. * Adding a new impostor for the impostor tracking.
  60375. * This will be done by the impostor itself.
  60376. * @param impostor the impostor to add
  60377. */
  60378. addImpostor(impostor: PhysicsImpostor): void;
  60379. /**
  60380. * Remove an impostor from the engine.
  60381. * This impostor and its mesh will not longer be updated by the physics engine.
  60382. * @param impostor the impostor to remove
  60383. */
  60384. removeImpostor(impostor: PhysicsImpostor): void;
  60385. /**
  60386. * Add a joint to the physics engine
  60387. * @param mainImpostor defines the main impostor to which the joint is added.
  60388. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60389. * @param joint defines the joint that will connect both impostors.
  60390. */
  60391. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60392. /**
  60393. * Removes a joint from the simulation
  60394. * @param mainImpostor defines the impostor used with the joint
  60395. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60396. * @param joint defines the joint to remove
  60397. */
  60398. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60399. /**
  60400. * Called by the scene. No need to call it.
  60401. * @param delta defines the timespam between frames
  60402. */
  60403. _step(delta: number): void;
  60404. /**
  60405. * Gets the current plugin used to run the simulation
  60406. * @returns current plugin
  60407. */
  60408. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60409. /**
  60410. * Gets the list of physic impostors
  60411. * @returns an array of PhysicsImpostor
  60412. */
  60413. getImpostors(): Array<PhysicsImpostor>;
  60414. /**
  60415. * Gets the impostor for a physics enabled object
  60416. * @param object defines the object impersonated by the impostor
  60417. * @returns the PhysicsImpostor or null if not found
  60418. */
  60419. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60420. /**
  60421. * Gets the impostor for a physics body object
  60422. * @param body defines physics body used by the impostor
  60423. * @returns the PhysicsImpostor or null if not found
  60424. */
  60425. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60426. /**
  60427. * Does a raycast in the physics world
  60428. * @param from when should the ray start?
  60429. * @param to when should the ray end?
  60430. * @returns PhysicsRaycastResult
  60431. */
  60432. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60433. }
  60434. }
  60435. declare module BABYLON {
  60436. /** @hidden */
  60437. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60438. private _useDeltaForWorldStep;
  60439. world: any;
  60440. name: string;
  60441. private _physicsMaterials;
  60442. private _fixedTimeStep;
  60443. private _cannonRaycastResult;
  60444. private _raycastResult;
  60445. private _physicsBodysToRemoveAfterStep;
  60446. private _firstFrame;
  60447. BJSCANNON: any;
  60448. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60449. setGravity(gravity: Vector3): void;
  60450. setTimeStep(timeStep: number): void;
  60451. getTimeStep(): number;
  60452. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60453. private _removeMarkedPhysicsBodiesFromWorld;
  60454. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60455. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60456. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60457. private _processChildMeshes;
  60458. removePhysicsBody(impostor: PhysicsImpostor): void;
  60459. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60460. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60461. private _addMaterial;
  60462. private _checkWithEpsilon;
  60463. private _createShape;
  60464. private _createHeightmap;
  60465. private _minus90X;
  60466. private _plus90X;
  60467. private _tmpPosition;
  60468. private _tmpDeltaPosition;
  60469. private _tmpUnityRotation;
  60470. private _updatePhysicsBodyTransformation;
  60471. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60472. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60473. isSupported(): boolean;
  60474. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60475. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60476. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60477. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60478. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60479. getBodyMass(impostor: PhysicsImpostor): number;
  60480. getBodyFriction(impostor: PhysicsImpostor): number;
  60481. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60482. getBodyRestitution(impostor: PhysicsImpostor): number;
  60483. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60484. sleepBody(impostor: PhysicsImpostor): void;
  60485. wakeUpBody(impostor: PhysicsImpostor): void;
  60486. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60487. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60488. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60489. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60490. getRadius(impostor: PhysicsImpostor): number;
  60491. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60492. dispose(): void;
  60493. private _extendNamespace;
  60494. /**
  60495. * Does a raycast in the physics world
  60496. * @param from when should the ray start?
  60497. * @param to when should the ray end?
  60498. * @returns PhysicsRaycastResult
  60499. */
  60500. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60501. }
  60502. }
  60503. declare module BABYLON {
  60504. /** @hidden */
  60505. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60506. private _useDeltaForWorldStep;
  60507. world: any;
  60508. name: string;
  60509. BJSOIMO: any;
  60510. private _raycastResult;
  60511. private _fixedTimeStep;
  60512. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60513. setGravity(gravity: Vector3): void;
  60514. setTimeStep(timeStep: number): void;
  60515. getTimeStep(): number;
  60516. private _tmpImpostorsArray;
  60517. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60518. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60519. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60520. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60521. private _tmpPositionVector;
  60522. removePhysicsBody(impostor: PhysicsImpostor): void;
  60523. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60524. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60525. isSupported(): boolean;
  60526. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60527. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60528. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60529. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60530. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60531. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60532. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60533. getBodyMass(impostor: PhysicsImpostor): number;
  60534. getBodyFriction(impostor: PhysicsImpostor): number;
  60535. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60536. getBodyRestitution(impostor: PhysicsImpostor): number;
  60537. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60538. sleepBody(impostor: PhysicsImpostor): void;
  60539. wakeUpBody(impostor: PhysicsImpostor): void;
  60540. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60541. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60542. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60543. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60544. getRadius(impostor: PhysicsImpostor): number;
  60545. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60546. dispose(): void;
  60547. /**
  60548. * Does a raycast in the physics world
  60549. * @param from when should the ray start?
  60550. * @param to when should the ray end?
  60551. * @returns PhysicsRaycastResult
  60552. */
  60553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60554. }
  60555. }
  60556. declare module BABYLON {
  60557. /**
  60558. * AmmoJS Physics plugin
  60559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60560. * @see https://github.com/kripken/ammo.js/
  60561. */
  60562. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60563. private _useDeltaForWorldStep;
  60564. /**
  60565. * Reference to the Ammo library
  60566. */
  60567. bjsAMMO: any;
  60568. /**
  60569. * Created ammoJS world which physics bodies are added to
  60570. */
  60571. world: any;
  60572. /**
  60573. * Name of the plugin
  60574. */
  60575. name: string;
  60576. private _timeStep;
  60577. private _fixedTimeStep;
  60578. private _maxSteps;
  60579. private _tmpQuaternion;
  60580. private _tmpAmmoTransform;
  60581. private _tmpAmmoQuaternion;
  60582. private _tmpAmmoConcreteContactResultCallback;
  60583. private _collisionConfiguration;
  60584. private _dispatcher;
  60585. private _overlappingPairCache;
  60586. private _solver;
  60587. private _softBodySolver;
  60588. private _tmpAmmoVectorA;
  60589. private _tmpAmmoVectorB;
  60590. private _tmpAmmoVectorC;
  60591. private _tmpAmmoVectorD;
  60592. private _tmpContactCallbackResult;
  60593. private _tmpAmmoVectorRCA;
  60594. private _tmpAmmoVectorRCB;
  60595. private _raycastResult;
  60596. private static readonly DISABLE_COLLISION_FLAG;
  60597. private static readonly KINEMATIC_FLAG;
  60598. private static readonly DISABLE_DEACTIVATION_FLAG;
  60599. /**
  60600. * Initializes the ammoJS plugin
  60601. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60602. * @param ammoInjection can be used to inject your own ammo reference
  60603. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60604. */
  60605. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60606. /**
  60607. * Sets the gravity of the physics world (m/(s^2))
  60608. * @param gravity Gravity to set
  60609. */
  60610. setGravity(gravity: Vector3): void;
  60611. /**
  60612. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60613. * @param timeStep timestep to use in seconds
  60614. */
  60615. setTimeStep(timeStep: number): void;
  60616. /**
  60617. * 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)
  60618. * @param fixedTimeStep fixedTimeStep to use in seconds
  60619. */
  60620. setFixedTimeStep(fixedTimeStep: number): void;
  60621. /**
  60622. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60623. * @param maxSteps the maximum number of steps by the physics engine per frame
  60624. */
  60625. setMaxSteps(maxSteps: number): void;
  60626. /**
  60627. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60628. * @returns the current timestep in seconds
  60629. */
  60630. getTimeStep(): number;
  60631. /**
  60632. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60633. */
  60634. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60635. private _isImpostorInContact;
  60636. private _isImpostorPairInContact;
  60637. private _stepSimulation;
  60638. /**
  60639. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60640. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60641. * After the step the babylon meshes are set to the position of the physics imposters
  60642. * @param delta amount of time to step forward
  60643. * @param impostors array of imposters to update before/after the step
  60644. */
  60645. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60646. /**
  60647. * Update babylon mesh to match physics world object
  60648. * @param impostor imposter to match
  60649. */
  60650. private _afterSoftStep;
  60651. /**
  60652. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60653. * @param impostor imposter to match
  60654. */
  60655. private _ropeStep;
  60656. /**
  60657. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60658. * @param impostor imposter to match
  60659. */
  60660. private _softbodyOrClothStep;
  60661. private _tmpMatrix;
  60662. /**
  60663. * Applies an impulse on the imposter
  60664. * @param impostor imposter to apply impulse to
  60665. * @param force amount of force to be applied to the imposter
  60666. * @param contactPoint the location to apply the impulse on the imposter
  60667. */
  60668. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60669. /**
  60670. * Applies a force on the imposter
  60671. * @param impostor imposter to apply force
  60672. * @param force amount of force to be applied to the imposter
  60673. * @param contactPoint the location to apply the force on the imposter
  60674. */
  60675. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60676. /**
  60677. * Creates a physics body using the plugin
  60678. * @param impostor the imposter to create the physics body on
  60679. */
  60680. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60681. /**
  60682. * Removes the physics body from the imposter and disposes of the body's memory
  60683. * @param impostor imposter to remove the physics body from
  60684. */
  60685. removePhysicsBody(impostor: PhysicsImpostor): void;
  60686. /**
  60687. * Generates a joint
  60688. * @param impostorJoint the imposter joint to create the joint with
  60689. */
  60690. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60691. /**
  60692. * Removes a joint
  60693. * @param impostorJoint the imposter joint to remove the joint from
  60694. */
  60695. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60696. private _addMeshVerts;
  60697. /**
  60698. * Initialise the soft body vertices to match its object's (mesh) vertices
  60699. * Softbody vertices (nodes) are in world space and to match this
  60700. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60701. * @param impostor to create the softbody for
  60702. */
  60703. private _softVertexData;
  60704. /**
  60705. * Create an impostor's soft body
  60706. * @param impostor to create the softbody for
  60707. */
  60708. private _createSoftbody;
  60709. /**
  60710. * Create cloth for an impostor
  60711. * @param impostor to create the softbody for
  60712. */
  60713. private _createCloth;
  60714. /**
  60715. * Create rope for an impostor
  60716. * @param impostor to create the softbody for
  60717. */
  60718. private _createRope;
  60719. /**
  60720. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60721. * @param impostor to create the custom physics shape for
  60722. */
  60723. private _createCustom;
  60724. private _addHullVerts;
  60725. private _createShape;
  60726. /**
  60727. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60728. * @param impostor imposter containing the physics body and babylon object
  60729. */
  60730. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60731. /**
  60732. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60733. * @param impostor imposter containing the physics body and babylon object
  60734. * @param newPosition new position
  60735. * @param newRotation new rotation
  60736. */
  60737. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60738. /**
  60739. * If this plugin is supported
  60740. * @returns true if its supported
  60741. */
  60742. isSupported(): boolean;
  60743. /**
  60744. * Sets the linear velocity of the physics body
  60745. * @param impostor imposter to set the velocity on
  60746. * @param velocity velocity to set
  60747. */
  60748. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60749. /**
  60750. * Sets the angular velocity of the physics body
  60751. * @param impostor imposter to set the velocity on
  60752. * @param velocity velocity to set
  60753. */
  60754. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60755. /**
  60756. * gets the linear velocity
  60757. * @param impostor imposter to get linear velocity from
  60758. * @returns linear velocity
  60759. */
  60760. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60761. /**
  60762. * gets the angular velocity
  60763. * @param impostor imposter to get angular velocity from
  60764. * @returns angular velocity
  60765. */
  60766. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60767. /**
  60768. * Sets the mass of physics body
  60769. * @param impostor imposter to set the mass on
  60770. * @param mass mass to set
  60771. */
  60772. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60773. /**
  60774. * Gets the mass of the physics body
  60775. * @param impostor imposter to get the mass from
  60776. * @returns mass
  60777. */
  60778. getBodyMass(impostor: PhysicsImpostor): number;
  60779. /**
  60780. * Gets friction of the impostor
  60781. * @param impostor impostor to get friction from
  60782. * @returns friction value
  60783. */
  60784. getBodyFriction(impostor: PhysicsImpostor): number;
  60785. /**
  60786. * Sets friction of the impostor
  60787. * @param impostor impostor to set friction on
  60788. * @param friction friction value
  60789. */
  60790. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60791. /**
  60792. * Gets restitution of the impostor
  60793. * @param impostor impostor to get restitution from
  60794. * @returns restitution value
  60795. */
  60796. getBodyRestitution(impostor: PhysicsImpostor): number;
  60797. /**
  60798. * Sets resitution of the impostor
  60799. * @param impostor impostor to set resitution on
  60800. * @param restitution resitution value
  60801. */
  60802. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60803. /**
  60804. * Gets pressure inside the impostor
  60805. * @param impostor impostor to get pressure from
  60806. * @returns pressure value
  60807. */
  60808. getBodyPressure(impostor: PhysicsImpostor): number;
  60809. /**
  60810. * Sets pressure inside a soft body impostor
  60811. * Cloth and rope must remain 0 pressure
  60812. * @param impostor impostor to set pressure on
  60813. * @param pressure pressure value
  60814. */
  60815. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60816. /**
  60817. * Gets stiffness of the impostor
  60818. * @param impostor impostor to get stiffness from
  60819. * @returns pressure value
  60820. */
  60821. getBodyStiffness(impostor: PhysicsImpostor): number;
  60822. /**
  60823. * Sets stiffness of the impostor
  60824. * @param impostor impostor to set stiffness on
  60825. * @param stiffness stiffness value from 0 to 1
  60826. */
  60827. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60828. /**
  60829. * Gets velocityIterations of the impostor
  60830. * @param impostor impostor to get velocity iterations from
  60831. * @returns velocityIterations value
  60832. */
  60833. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60834. /**
  60835. * Sets velocityIterations of the impostor
  60836. * @param impostor impostor to set velocity iterations on
  60837. * @param velocityIterations velocityIterations value
  60838. */
  60839. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60840. /**
  60841. * Gets positionIterations of the impostor
  60842. * @param impostor impostor to get position iterations from
  60843. * @returns positionIterations value
  60844. */
  60845. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60846. /**
  60847. * Sets positionIterations of the impostor
  60848. * @param impostor impostor to set position on
  60849. * @param positionIterations positionIterations value
  60850. */
  60851. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60852. /**
  60853. * Append an anchor to a cloth object
  60854. * @param impostor is the cloth impostor to add anchor to
  60855. * @param otherImpostor is the rigid impostor to anchor to
  60856. * @param width ratio across width from 0 to 1
  60857. * @param height ratio up height from 0 to 1
  60858. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60859. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60860. */
  60861. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60862. /**
  60863. * Append an hook to a rope object
  60864. * @param impostor is the rope impostor to add hook to
  60865. * @param otherImpostor is the rigid impostor to hook to
  60866. * @param length ratio along the rope from 0 to 1
  60867. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60868. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60869. */
  60870. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60871. /**
  60872. * Sleeps the physics body and stops it from being active
  60873. * @param impostor impostor to sleep
  60874. */
  60875. sleepBody(impostor: PhysicsImpostor): void;
  60876. /**
  60877. * Activates the physics body
  60878. * @param impostor impostor to activate
  60879. */
  60880. wakeUpBody(impostor: PhysicsImpostor): void;
  60881. /**
  60882. * Updates the distance parameters of the joint
  60883. * @param joint joint to update
  60884. * @param maxDistance maximum distance of the joint
  60885. * @param minDistance minimum distance of the joint
  60886. */
  60887. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60888. /**
  60889. * Sets a motor on the joint
  60890. * @param joint joint to set motor on
  60891. * @param speed speed of the motor
  60892. * @param maxForce maximum force of the motor
  60893. * @param motorIndex index of the motor
  60894. */
  60895. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60896. /**
  60897. * Sets the motors limit
  60898. * @param joint joint to set limit on
  60899. * @param upperLimit upper limit
  60900. * @param lowerLimit lower limit
  60901. */
  60902. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60903. /**
  60904. * Syncs the position and rotation of a mesh with the impostor
  60905. * @param mesh mesh to sync
  60906. * @param impostor impostor to update the mesh with
  60907. */
  60908. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60909. /**
  60910. * Gets the radius of the impostor
  60911. * @param impostor impostor to get radius from
  60912. * @returns the radius
  60913. */
  60914. getRadius(impostor: PhysicsImpostor): number;
  60915. /**
  60916. * Gets the box size of the impostor
  60917. * @param impostor impostor to get box size from
  60918. * @param result the resulting box size
  60919. */
  60920. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60921. /**
  60922. * Disposes of the impostor
  60923. */
  60924. dispose(): void;
  60925. /**
  60926. * Does a raycast in the physics world
  60927. * @param from when should the ray start?
  60928. * @param to when should the ray end?
  60929. * @returns PhysicsRaycastResult
  60930. */
  60931. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60932. }
  60933. }
  60934. declare module BABYLON {
  60935. interface AbstractScene {
  60936. /**
  60937. * The list of reflection probes added to the scene
  60938. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60939. */
  60940. reflectionProbes: Array<ReflectionProbe>;
  60941. /**
  60942. * Removes the given reflection probe from this scene.
  60943. * @param toRemove The reflection probe to remove
  60944. * @returns The index of the removed reflection probe
  60945. */
  60946. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60947. /**
  60948. * Adds the given reflection probe to this scene.
  60949. * @param newReflectionProbe The reflection probe to add
  60950. */
  60951. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60952. }
  60953. /**
  60954. * Class used to generate realtime reflection / refraction cube textures
  60955. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60956. */
  60957. export class ReflectionProbe {
  60958. /** defines the name of the probe */
  60959. name: string;
  60960. private _scene;
  60961. private _renderTargetTexture;
  60962. private _projectionMatrix;
  60963. private _viewMatrix;
  60964. private _target;
  60965. private _add;
  60966. private _attachedMesh;
  60967. private _invertYAxis;
  60968. /** Gets or sets probe position (center of the cube map) */
  60969. position: Vector3;
  60970. /**
  60971. * Creates a new reflection probe
  60972. * @param name defines the name of the probe
  60973. * @param size defines the texture resolution (for each face)
  60974. * @param scene defines the hosting scene
  60975. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60976. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60977. */
  60978. constructor(
  60979. /** defines the name of the probe */
  60980. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60981. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60982. get samples(): number;
  60983. set samples(value: number);
  60984. /** Gets or sets the refresh rate to use (on every frame by default) */
  60985. get refreshRate(): number;
  60986. set refreshRate(value: number);
  60987. /**
  60988. * Gets the hosting scene
  60989. * @returns a Scene
  60990. */
  60991. getScene(): Scene;
  60992. /** Gets the internal CubeTexture used to render to */
  60993. get cubeTexture(): RenderTargetTexture;
  60994. /** Gets the list of meshes to render */
  60995. get renderList(): Nullable<AbstractMesh[]>;
  60996. /**
  60997. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60998. * @param mesh defines the mesh to attach to
  60999. */
  61000. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61001. /**
  61002. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61003. * @param renderingGroupId The rendering group id corresponding to its index
  61004. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61005. */
  61006. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61007. /**
  61008. * Clean all associated resources
  61009. */
  61010. dispose(): void;
  61011. /**
  61012. * Converts the reflection probe information to a readable string for debug purpose.
  61013. * @param fullDetails Supports for multiple levels of logging within scene loading
  61014. * @returns the human readable reflection probe info
  61015. */
  61016. toString(fullDetails?: boolean): string;
  61017. /**
  61018. * Get the class name of the relfection probe.
  61019. * @returns "ReflectionProbe"
  61020. */
  61021. getClassName(): string;
  61022. /**
  61023. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61024. * @returns The JSON representation of the texture
  61025. */
  61026. serialize(): any;
  61027. /**
  61028. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61029. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61030. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61031. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61032. * @returns The parsed reflection probe if successful
  61033. */
  61034. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61035. }
  61036. }
  61037. declare module BABYLON {
  61038. /** @hidden */
  61039. export var _BabylonLoaderRegistered: boolean;
  61040. /**
  61041. * Helps setting up some configuration for the babylon file loader.
  61042. */
  61043. export class BabylonFileLoaderConfiguration {
  61044. /**
  61045. * The loader does not allow injecting custom physix engine into the plugins.
  61046. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61047. * So you could set this variable to your engine import to make it work.
  61048. */
  61049. static LoaderInjectedPhysicsEngine: any;
  61050. }
  61051. }
  61052. declare module BABYLON {
  61053. /**
  61054. * The Physically based simple base material of BJS.
  61055. *
  61056. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61057. * It is used as the base class for both the specGloss and metalRough conventions.
  61058. */
  61059. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61060. /**
  61061. * Number of Simultaneous lights allowed on the material.
  61062. */
  61063. maxSimultaneousLights: number;
  61064. /**
  61065. * If sets to true, disables all the lights affecting the material.
  61066. */
  61067. disableLighting: boolean;
  61068. /**
  61069. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61070. */
  61071. environmentTexture: BaseTexture;
  61072. /**
  61073. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61074. */
  61075. invertNormalMapX: boolean;
  61076. /**
  61077. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61078. */
  61079. invertNormalMapY: boolean;
  61080. /**
  61081. * Normal map used in the model.
  61082. */
  61083. normalTexture: BaseTexture;
  61084. /**
  61085. * Emissivie color used to self-illuminate the model.
  61086. */
  61087. emissiveColor: Color3;
  61088. /**
  61089. * Emissivie texture used to self-illuminate the model.
  61090. */
  61091. emissiveTexture: BaseTexture;
  61092. /**
  61093. * Occlusion Channel Strenght.
  61094. */
  61095. occlusionStrength: number;
  61096. /**
  61097. * Occlusion Texture of the material (adding extra occlusion effects).
  61098. */
  61099. occlusionTexture: BaseTexture;
  61100. /**
  61101. * Defines the alpha limits in alpha test mode.
  61102. */
  61103. alphaCutOff: number;
  61104. /**
  61105. * Gets the current double sided mode.
  61106. */
  61107. get doubleSided(): boolean;
  61108. /**
  61109. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61110. */
  61111. set doubleSided(value: boolean);
  61112. /**
  61113. * Stores the pre-calculated light information of a mesh in a texture.
  61114. */
  61115. lightmapTexture: BaseTexture;
  61116. /**
  61117. * If true, the light map contains occlusion information instead of lighting info.
  61118. */
  61119. useLightmapAsShadowmap: boolean;
  61120. /**
  61121. * Instantiates a new PBRMaterial instance.
  61122. *
  61123. * @param name The material name
  61124. * @param scene The scene the material will be use in.
  61125. */
  61126. constructor(name: string, scene: Scene);
  61127. getClassName(): string;
  61128. }
  61129. }
  61130. declare module BABYLON {
  61131. /**
  61132. * The PBR material of BJS following the metal roughness convention.
  61133. *
  61134. * This fits to the PBR convention in the GLTF definition:
  61135. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61136. */
  61137. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61138. /**
  61139. * The base color has two different interpretations depending on the value of metalness.
  61140. * When the material is a metal, the base color is the specific measured reflectance value
  61141. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61142. * of the material.
  61143. */
  61144. baseColor: Color3;
  61145. /**
  61146. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61147. * well as opacity information in the alpha channel.
  61148. */
  61149. baseTexture: BaseTexture;
  61150. /**
  61151. * Specifies the metallic scalar value of the material.
  61152. * Can also be used to scale the metalness values of the metallic texture.
  61153. */
  61154. metallic: number;
  61155. /**
  61156. * Specifies the roughness scalar value of the material.
  61157. * Can also be used to scale the roughness values of the metallic texture.
  61158. */
  61159. roughness: number;
  61160. /**
  61161. * Texture containing both the metallic value in the B channel and the
  61162. * roughness value in the G channel to keep better precision.
  61163. */
  61164. metallicRoughnessTexture: BaseTexture;
  61165. /**
  61166. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61167. *
  61168. * @param name The material name
  61169. * @param scene The scene the material will be use in.
  61170. */
  61171. constructor(name: string, scene: Scene);
  61172. /**
  61173. * Return the currrent class name of the material.
  61174. */
  61175. getClassName(): string;
  61176. /**
  61177. * Makes a duplicate of the current material.
  61178. * @param name - name to use for the new material.
  61179. */
  61180. clone(name: string): PBRMetallicRoughnessMaterial;
  61181. /**
  61182. * Serialize the material to a parsable JSON object.
  61183. */
  61184. serialize(): any;
  61185. /**
  61186. * Parses a JSON object correponding to the serialize function.
  61187. */
  61188. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61189. }
  61190. }
  61191. declare module BABYLON {
  61192. /**
  61193. * The PBR material of BJS following the specular glossiness convention.
  61194. *
  61195. * This fits to the PBR convention in the GLTF definition:
  61196. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61197. */
  61198. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61199. /**
  61200. * Specifies the diffuse color of the material.
  61201. */
  61202. diffuseColor: Color3;
  61203. /**
  61204. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61205. * channel.
  61206. */
  61207. diffuseTexture: BaseTexture;
  61208. /**
  61209. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61210. */
  61211. specularColor: Color3;
  61212. /**
  61213. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61214. */
  61215. glossiness: number;
  61216. /**
  61217. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61218. */
  61219. specularGlossinessTexture: BaseTexture;
  61220. /**
  61221. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61222. *
  61223. * @param name The material name
  61224. * @param scene The scene the material will be use in.
  61225. */
  61226. constructor(name: string, scene: Scene);
  61227. /**
  61228. * Return the currrent class name of the material.
  61229. */
  61230. getClassName(): string;
  61231. /**
  61232. * Makes a duplicate of the current material.
  61233. * @param name - name to use for the new material.
  61234. */
  61235. clone(name: string): PBRSpecularGlossinessMaterial;
  61236. /**
  61237. * Serialize the material to a parsable JSON object.
  61238. */
  61239. serialize(): any;
  61240. /**
  61241. * Parses a JSON object correponding to the serialize function.
  61242. */
  61243. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61244. }
  61245. }
  61246. declare module BABYLON {
  61247. /**
  61248. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61249. * It can help converting any input color in a desired output one. This can then be used to create effects
  61250. * from sepia, black and white to sixties or futuristic rendering...
  61251. *
  61252. * The only supported format is currently 3dl.
  61253. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61254. */
  61255. export class ColorGradingTexture extends BaseTexture {
  61256. /**
  61257. * The texture URL.
  61258. */
  61259. url: string;
  61260. /**
  61261. * Empty line regex stored for GC.
  61262. */
  61263. private static _noneEmptyLineRegex;
  61264. private _textureMatrix;
  61265. private _onLoad;
  61266. /**
  61267. * Instantiates a ColorGradingTexture from the following parameters.
  61268. *
  61269. * @param url The location of the color gradind data (currently only supporting 3dl)
  61270. * @param sceneOrEngine The scene or engine the texture will be used in
  61271. * @param onLoad defines a callback triggered when the texture has been loaded
  61272. */
  61273. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61274. /**
  61275. * Fires the onload event from the constructor if requested.
  61276. */
  61277. private _triggerOnLoad;
  61278. /**
  61279. * Returns the texture matrix used in most of the material.
  61280. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61281. */
  61282. getTextureMatrix(): Matrix;
  61283. /**
  61284. * Occurs when the file being loaded is a .3dl LUT file.
  61285. */
  61286. private load3dlTexture;
  61287. /**
  61288. * Starts the loading process of the texture.
  61289. */
  61290. private loadTexture;
  61291. /**
  61292. * Clones the color gradind texture.
  61293. */
  61294. clone(): ColorGradingTexture;
  61295. /**
  61296. * Called during delayed load for textures.
  61297. */
  61298. delayLoad(): void;
  61299. /**
  61300. * Parses a color grading texture serialized by Babylon.
  61301. * @param parsedTexture The texture information being parsedTexture
  61302. * @param scene The scene to load the texture in
  61303. * @param rootUrl The root url of the data assets to load
  61304. * @return A color gradind texture
  61305. */
  61306. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61307. /**
  61308. * Serializes the LUT texture to json format.
  61309. */
  61310. serialize(): any;
  61311. }
  61312. }
  61313. declare module BABYLON {
  61314. /**
  61315. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61316. */
  61317. export class EquiRectangularCubeTexture extends BaseTexture {
  61318. /** The six faces of the cube. */
  61319. private static _FacesMapping;
  61320. private _noMipmap;
  61321. private _onLoad;
  61322. private _onError;
  61323. /** The size of the cubemap. */
  61324. private _size;
  61325. /** The buffer of the image. */
  61326. private _buffer;
  61327. /** The width of the input image. */
  61328. private _width;
  61329. /** The height of the input image. */
  61330. private _height;
  61331. /** The URL to the image. */
  61332. url: string;
  61333. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  61334. coordinatesMode: number;
  61335. /**
  61336. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61337. * @param url The location of the image
  61338. * @param scene The scene the texture will be used in
  61339. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61340. * @param noMipmap Forces to not generate the mipmap if true
  61341. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61342. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61343. * @param onLoad — defines a callback called when texture is loaded
  61344. * @param onError — defines a callback called if there is an error
  61345. */
  61346. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61347. /**
  61348. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61349. */
  61350. private loadImage;
  61351. /**
  61352. * Convert the image buffer into a cubemap and create a CubeTexture.
  61353. */
  61354. private loadTexture;
  61355. /**
  61356. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61357. * @param buffer The ArrayBuffer that should be converted.
  61358. * @returns The buffer as Float32Array.
  61359. */
  61360. private getFloat32ArrayFromArrayBuffer;
  61361. /**
  61362. * Get the current class name of the texture useful for serialization or dynamic coding.
  61363. * @returns "EquiRectangularCubeTexture"
  61364. */
  61365. getClassName(): string;
  61366. /**
  61367. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61368. * @returns A clone of the current EquiRectangularCubeTexture.
  61369. */
  61370. clone(): EquiRectangularCubeTexture;
  61371. }
  61372. }
  61373. declare module BABYLON {
  61374. /**
  61375. * Defines the options related to the creation of an HtmlElementTexture
  61376. */
  61377. export interface IHtmlElementTextureOptions {
  61378. /**
  61379. * Defines wether mip maps should be created or not.
  61380. */
  61381. generateMipMaps?: boolean;
  61382. /**
  61383. * Defines the sampling mode of the texture.
  61384. */
  61385. samplingMode?: number;
  61386. /**
  61387. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61388. */
  61389. engine: Nullable<ThinEngine>;
  61390. /**
  61391. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61392. */
  61393. scene: Nullable<Scene>;
  61394. }
  61395. /**
  61396. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61397. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61398. * is automatically managed.
  61399. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61400. * in your application.
  61401. *
  61402. * As the update is not automatic, you need to call them manually.
  61403. */
  61404. export class HtmlElementTexture extends BaseTexture {
  61405. /**
  61406. * The texture URL.
  61407. */
  61408. element: HTMLVideoElement | HTMLCanvasElement;
  61409. private static readonly DefaultOptions;
  61410. private _textureMatrix;
  61411. private _isVideo;
  61412. private _generateMipMaps;
  61413. private _samplingMode;
  61414. /**
  61415. * Instantiates a HtmlElementTexture from the following parameters.
  61416. *
  61417. * @param name Defines the name of the texture
  61418. * @param element Defines the video or canvas the texture is filled with
  61419. * @param options Defines the other none mandatory texture creation options
  61420. */
  61421. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61422. private _createInternalTexture;
  61423. /**
  61424. * Returns the texture matrix used in most of the material.
  61425. */
  61426. getTextureMatrix(): Matrix;
  61427. /**
  61428. * Updates the content of the texture.
  61429. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61430. */
  61431. update(invertY?: Nullable<boolean>): void;
  61432. }
  61433. }
  61434. declare module BABYLON {
  61435. /**
  61436. * Based on jsTGALoader - Javascript loader for TGA file
  61437. * By Vincent Thibault
  61438. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61439. */
  61440. export class TGATools {
  61441. private static _TYPE_INDEXED;
  61442. private static _TYPE_RGB;
  61443. private static _TYPE_GREY;
  61444. private static _TYPE_RLE_INDEXED;
  61445. private static _TYPE_RLE_RGB;
  61446. private static _TYPE_RLE_GREY;
  61447. private static _ORIGIN_MASK;
  61448. private static _ORIGIN_SHIFT;
  61449. private static _ORIGIN_BL;
  61450. private static _ORIGIN_BR;
  61451. private static _ORIGIN_UL;
  61452. private static _ORIGIN_UR;
  61453. /**
  61454. * Gets the header of a TGA file
  61455. * @param data defines the TGA data
  61456. * @returns the header
  61457. */
  61458. static GetTGAHeader(data: Uint8Array): any;
  61459. /**
  61460. * Uploads TGA content to a Babylon Texture
  61461. * @hidden
  61462. */
  61463. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61464. /** @hidden */
  61465. 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;
  61466. /** @hidden */
  61467. 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;
  61468. /** @hidden */
  61469. 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;
  61470. /** @hidden */
  61471. 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;
  61472. /** @hidden */
  61473. 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;
  61474. /** @hidden */
  61475. 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;
  61476. }
  61477. }
  61478. declare module BABYLON {
  61479. /**
  61480. * Implementation of the TGA Texture Loader.
  61481. * @hidden
  61482. */
  61483. export class _TGATextureLoader implements IInternalTextureLoader {
  61484. /**
  61485. * Defines wether the loader supports cascade loading the different faces.
  61486. */
  61487. readonly supportCascades: boolean;
  61488. /**
  61489. * This returns if the loader support the current file information.
  61490. * @param extension defines the file extension of the file being loaded
  61491. * @returns true if the loader can load the specified file
  61492. */
  61493. canLoad(extension: string): boolean;
  61494. /**
  61495. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61496. * @param data contains the texture data
  61497. * @param texture defines the BabylonJS internal texture
  61498. * @param createPolynomials will be true if polynomials have been requested
  61499. * @param onLoad defines the callback to trigger once the texture is ready
  61500. * @param onError defines the callback to trigger in case of error
  61501. */
  61502. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61503. /**
  61504. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61505. * @param data contains the texture data
  61506. * @param texture defines the BabylonJS internal texture
  61507. * @param callback defines the method to call once ready to upload
  61508. */
  61509. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61510. }
  61511. }
  61512. declare module BABYLON {
  61513. /**
  61514. * Info about the .basis files
  61515. */
  61516. class BasisFileInfo {
  61517. /**
  61518. * If the file has alpha
  61519. */
  61520. hasAlpha: boolean;
  61521. /**
  61522. * Info about each image of the basis file
  61523. */
  61524. images: Array<{
  61525. levels: Array<{
  61526. width: number;
  61527. height: number;
  61528. transcodedPixels: ArrayBufferView;
  61529. }>;
  61530. }>;
  61531. }
  61532. /**
  61533. * Result of transcoding a basis file
  61534. */
  61535. class TranscodeResult {
  61536. /**
  61537. * Info about the .basis file
  61538. */
  61539. fileInfo: BasisFileInfo;
  61540. /**
  61541. * Format to use when loading the file
  61542. */
  61543. format: number;
  61544. }
  61545. /**
  61546. * Configuration options for the Basis transcoder
  61547. */
  61548. export class BasisTranscodeConfiguration {
  61549. /**
  61550. * Supported compression formats used to determine the supported output format of the transcoder
  61551. */
  61552. supportedCompressionFormats?: {
  61553. /**
  61554. * etc1 compression format
  61555. */
  61556. etc1?: boolean;
  61557. /**
  61558. * s3tc compression format
  61559. */
  61560. s3tc?: boolean;
  61561. /**
  61562. * pvrtc compression format
  61563. */
  61564. pvrtc?: boolean;
  61565. /**
  61566. * etc2 compression format
  61567. */
  61568. etc2?: boolean;
  61569. };
  61570. /**
  61571. * If mipmap levels should be loaded for transcoded images (Default: true)
  61572. */
  61573. loadMipmapLevels?: boolean;
  61574. /**
  61575. * Index of a single image to load (Default: all images)
  61576. */
  61577. loadSingleImage?: number;
  61578. }
  61579. /**
  61580. * Used to load .Basis files
  61581. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61582. */
  61583. export class BasisTools {
  61584. private static _IgnoreSupportedFormats;
  61585. /**
  61586. * URL to use when loading the basis transcoder
  61587. */
  61588. static JSModuleURL: string;
  61589. /**
  61590. * URL to use when loading the wasm module for the transcoder
  61591. */
  61592. static WasmModuleURL: string;
  61593. /**
  61594. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61595. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61596. * @returns internal format corresponding to the Basis format
  61597. */
  61598. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61599. private static _WorkerPromise;
  61600. private static _Worker;
  61601. private static _actionId;
  61602. private static _CreateWorkerAsync;
  61603. /**
  61604. * Transcodes a loaded image file to compressed pixel data
  61605. * @param data image data to transcode
  61606. * @param config configuration options for the transcoding
  61607. * @returns a promise resulting in the transcoded image
  61608. */
  61609. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61610. /**
  61611. * Loads a texture from the transcode result
  61612. * @param texture texture load to
  61613. * @param transcodeResult the result of transcoding the basis file to load from
  61614. */
  61615. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61616. }
  61617. }
  61618. declare module BABYLON {
  61619. /**
  61620. * Loader for .basis file format
  61621. */
  61622. export class _BasisTextureLoader implements IInternalTextureLoader {
  61623. /**
  61624. * Defines whether the loader supports cascade loading the different faces.
  61625. */
  61626. readonly supportCascades: boolean;
  61627. /**
  61628. * This returns if the loader support the current file information.
  61629. * @param extension defines the file extension of the file being loaded
  61630. * @returns true if the loader can load the specified file
  61631. */
  61632. canLoad(extension: string): boolean;
  61633. /**
  61634. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61635. * @param data contains the texture data
  61636. * @param texture defines the BabylonJS internal texture
  61637. * @param createPolynomials will be true if polynomials have been requested
  61638. * @param onLoad defines the callback to trigger once the texture is ready
  61639. * @param onError defines the callback to trigger in case of error
  61640. */
  61641. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61642. /**
  61643. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61644. * @param data contains the texture data
  61645. * @param texture defines the BabylonJS internal texture
  61646. * @param callback defines the method to call once ready to upload
  61647. */
  61648. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61649. }
  61650. }
  61651. declare module BABYLON {
  61652. /**
  61653. * Defines the basic options interface of a TexturePacker Frame
  61654. */
  61655. export interface ITexturePackerFrame {
  61656. /**
  61657. * The frame ID
  61658. */
  61659. id: number;
  61660. /**
  61661. * The frames Scale
  61662. */
  61663. scale: Vector2;
  61664. /**
  61665. * The Frames offset
  61666. */
  61667. offset: Vector2;
  61668. }
  61669. /**
  61670. * This is a support class for frame Data on texture packer sets.
  61671. */
  61672. export class TexturePackerFrame implements ITexturePackerFrame {
  61673. /**
  61674. * The frame ID
  61675. */
  61676. id: number;
  61677. /**
  61678. * The frames Scale
  61679. */
  61680. scale: Vector2;
  61681. /**
  61682. * The Frames offset
  61683. */
  61684. offset: Vector2;
  61685. /**
  61686. * Initializes a texture package frame.
  61687. * @param id The numerical frame identifier
  61688. * @param scale Scalar Vector2 for UV frame
  61689. * @param offset Vector2 for the frame position in UV units.
  61690. * @returns TexturePackerFrame
  61691. */
  61692. constructor(id: number, scale: Vector2, offset: Vector2);
  61693. }
  61694. }
  61695. declare module BABYLON {
  61696. /**
  61697. * Defines the basic options interface of a TexturePacker
  61698. */
  61699. export interface ITexturePackerOptions {
  61700. /**
  61701. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61702. */
  61703. map?: string[];
  61704. /**
  61705. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61706. */
  61707. uvsIn?: string;
  61708. /**
  61709. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61710. */
  61711. uvsOut?: string;
  61712. /**
  61713. * number representing the layout style. Defaults to LAYOUT_STRIP
  61714. */
  61715. layout?: number;
  61716. /**
  61717. * number of columns if using custom column count layout(2). This defaults to 4.
  61718. */
  61719. colnum?: number;
  61720. /**
  61721. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61722. */
  61723. updateInputMeshes?: boolean;
  61724. /**
  61725. * boolean flag to dispose all the source textures. Defaults to true.
  61726. */
  61727. disposeSources?: boolean;
  61728. /**
  61729. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61730. */
  61731. fillBlanks?: boolean;
  61732. /**
  61733. * string value representing the context fill style color. Defaults to 'black'.
  61734. */
  61735. customFillColor?: string;
  61736. /**
  61737. * Width and Height Value of each Frame in the TexturePacker Sets
  61738. */
  61739. frameSize?: number;
  61740. /**
  61741. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61742. */
  61743. paddingRatio?: number;
  61744. /**
  61745. * Number that declares the fill method for the padding gutter.
  61746. */
  61747. paddingMode?: number;
  61748. /**
  61749. * If in SUBUV_COLOR padding mode what color to use.
  61750. */
  61751. paddingColor?: Color3 | Color4;
  61752. }
  61753. /**
  61754. * Defines the basic interface of a TexturePacker JSON File
  61755. */
  61756. export interface ITexturePackerJSON {
  61757. /**
  61758. * The frame ID
  61759. */
  61760. name: string;
  61761. /**
  61762. * The base64 channel data
  61763. */
  61764. sets: any;
  61765. /**
  61766. * The options of the Packer
  61767. */
  61768. options: ITexturePackerOptions;
  61769. /**
  61770. * The frame data of the Packer
  61771. */
  61772. frames: Array<number>;
  61773. }
  61774. /**
  61775. * This is a support class that generates a series of packed texture sets.
  61776. * @see https://doc.babylonjs.com/babylon101/materials
  61777. */
  61778. export class TexturePacker {
  61779. /** Packer Layout Constant 0 */
  61780. static readonly LAYOUT_STRIP: number;
  61781. /** Packer Layout Constant 1 */
  61782. static readonly LAYOUT_POWER2: number;
  61783. /** Packer Layout Constant 2 */
  61784. static readonly LAYOUT_COLNUM: number;
  61785. /** Packer Layout Constant 0 */
  61786. static readonly SUBUV_WRAP: number;
  61787. /** Packer Layout Constant 1 */
  61788. static readonly SUBUV_EXTEND: number;
  61789. /** Packer Layout Constant 2 */
  61790. static readonly SUBUV_COLOR: number;
  61791. /** The Name of the Texture Package */
  61792. name: string;
  61793. /** The scene scope of the TexturePacker */
  61794. scene: Scene;
  61795. /** The Meshes to target */
  61796. meshes: AbstractMesh[];
  61797. /** Arguments passed with the Constructor */
  61798. options: ITexturePackerOptions;
  61799. /** The promise that is started upon initialization */
  61800. promise: Nullable<Promise<TexturePacker | string>>;
  61801. /** The Container object for the channel sets that are generated */
  61802. sets: object;
  61803. /** The Container array for the frames that are generated */
  61804. frames: TexturePackerFrame[];
  61805. /** The expected number of textures the system is parsing. */
  61806. private _expecting;
  61807. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61808. private _paddingValue;
  61809. /**
  61810. * Initializes a texture package series from an array of meshes or a single mesh.
  61811. * @param name The name of the package
  61812. * @param meshes The target meshes to compose the package from
  61813. * @param options The arguments that texture packer should follow while building.
  61814. * @param scene The scene which the textures are scoped to.
  61815. * @returns TexturePacker
  61816. */
  61817. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61818. /**
  61819. * Starts the package process
  61820. * @param resolve The promises resolution function
  61821. * @returns TexturePacker
  61822. */
  61823. private _createFrames;
  61824. /**
  61825. * Calculates the Size of the Channel Sets
  61826. * @returns Vector2
  61827. */
  61828. private _calculateSize;
  61829. /**
  61830. * Calculates the UV data for the frames.
  61831. * @param baseSize the base frameSize
  61832. * @param padding the base frame padding
  61833. * @param dtSize size of the Dynamic Texture for that channel
  61834. * @param dtUnits is 1/dtSize
  61835. * @param update flag to update the input meshes
  61836. */
  61837. private _calculateMeshUVFrames;
  61838. /**
  61839. * Calculates the frames Offset.
  61840. * @param index of the frame
  61841. * @returns Vector2
  61842. */
  61843. private _getFrameOffset;
  61844. /**
  61845. * Updates a Mesh to the frame data
  61846. * @param mesh that is the target
  61847. * @param frameID or the frame index
  61848. */
  61849. private _updateMeshUV;
  61850. /**
  61851. * Updates a Meshes materials to use the texture packer channels
  61852. * @param m is the mesh to target
  61853. * @param force all channels on the packer to be set.
  61854. */
  61855. private _updateTextureReferences;
  61856. /**
  61857. * Public method to set a Mesh to a frame
  61858. * @param m that is the target
  61859. * @param frameID or the frame index
  61860. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61861. */
  61862. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61863. /**
  61864. * Starts the async promise to compile the texture packer.
  61865. * @returns Promise<void>
  61866. */
  61867. processAsync(): Promise<void>;
  61868. /**
  61869. * Disposes all textures associated with this packer
  61870. */
  61871. dispose(): void;
  61872. /**
  61873. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61874. * @param imageType is the image type to use.
  61875. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61876. */
  61877. download(imageType?: string, quality?: number): void;
  61878. /**
  61879. * Public method to load a texturePacker JSON file.
  61880. * @param data of the JSON file in string format.
  61881. */
  61882. updateFromJSON(data: string): void;
  61883. }
  61884. }
  61885. declare module BABYLON {
  61886. /**
  61887. * 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.
  61888. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61889. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61890. */
  61891. export class CustomProceduralTexture extends ProceduralTexture {
  61892. private _animate;
  61893. private _time;
  61894. private _config;
  61895. private _texturePath;
  61896. /**
  61897. * Instantiates a new Custom Procedural Texture.
  61898. * 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.
  61899. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61900. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61901. * @param name Define the name of the texture
  61902. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61903. * @param size Define the size of the texture to create
  61904. * @param scene Define the scene the texture belongs to
  61905. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61906. * @param generateMipMaps Define if the texture should creates mip maps or not
  61907. */
  61908. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61909. private _loadJson;
  61910. /**
  61911. * Is the texture ready to be used ? (rendered at least once)
  61912. * @returns true if ready, otherwise, false.
  61913. */
  61914. isReady(): boolean;
  61915. /**
  61916. * Render the texture to its associated render target.
  61917. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61918. */
  61919. render(useCameraPostProcess?: boolean): void;
  61920. /**
  61921. * Update the list of dependant textures samplers in the shader.
  61922. */
  61923. updateTextures(): void;
  61924. /**
  61925. * Update the uniform values of the procedural texture in the shader.
  61926. */
  61927. updateShaderUniforms(): void;
  61928. /**
  61929. * Define if the texture animates or not.
  61930. */
  61931. get animate(): boolean;
  61932. set animate(value: boolean);
  61933. }
  61934. }
  61935. declare module BABYLON {
  61936. /** @hidden */
  61937. export var noisePixelShader: {
  61938. name: string;
  61939. shader: string;
  61940. };
  61941. }
  61942. declare module BABYLON {
  61943. /**
  61944. * Class used to generate noise procedural textures
  61945. */
  61946. export class NoiseProceduralTexture extends ProceduralTexture {
  61947. private _time;
  61948. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61949. brightness: number;
  61950. /** Defines the number of octaves to process */
  61951. octaves: number;
  61952. /** Defines the level of persistence (0.8 by default) */
  61953. persistence: number;
  61954. /** Gets or sets animation speed factor (default is 1) */
  61955. animationSpeedFactor: number;
  61956. /**
  61957. * Creates a new NoiseProceduralTexture
  61958. * @param name defines the name fo the texture
  61959. * @param size defines the size of the texture (default is 256)
  61960. * @param scene defines the hosting scene
  61961. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61962. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61963. */
  61964. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61965. private _updateShaderUniforms;
  61966. protected _getDefines(): string;
  61967. /** Generate the current state of the procedural texture */
  61968. render(useCameraPostProcess?: boolean): void;
  61969. /**
  61970. * Serializes this noise procedural texture
  61971. * @returns a serialized noise procedural texture object
  61972. */
  61973. serialize(): any;
  61974. /**
  61975. * Clone the texture.
  61976. * @returns the cloned texture
  61977. */
  61978. clone(): NoiseProceduralTexture;
  61979. /**
  61980. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61981. * @param parsedTexture defines parsed texture data
  61982. * @param scene defines the current scene
  61983. * @param rootUrl defines the root URL containing noise procedural texture information
  61984. * @returns a parsed NoiseProceduralTexture
  61985. */
  61986. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61987. }
  61988. }
  61989. declare module BABYLON {
  61990. /**
  61991. * Raw cube texture where the raw buffers are passed in
  61992. */
  61993. export class RawCubeTexture extends CubeTexture {
  61994. /**
  61995. * Creates a cube texture where the raw buffers are passed in.
  61996. * @param scene defines the scene the texture is attached to
  61997. * @param data defines the array of data to use to create each face
  61998. * @param size defines the size of the textures
  61999. * @param format defines the format of the data
  62000. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62001. * @param generateMipMaps defines if the engine should generate the mip levels
  62002. * @param invertY defines if data must be stored with Y axis inverted
  62003. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62004. * @param compression defines the compression used (null by default)
  62005. */
  62006. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62007. /**
  62008. * Updates the raw cube texture.
  62009. * @param data defines the data to store
  62010. * @param format defines the data format
  62011. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62012. * @param invertY defines if data must be stored with Y axis inverted
  62013. * @param compression defines the compression used (null by default)
  62014. * @param level defines which level of the texture to update
  62015. */
  62016. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62017. /**
  62018. * Updates a raw cube texture with RGBD encoded data.
  62019. * @param data defines the array of data [mipmap][face] to use to create each face
  62020. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62021. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62022. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62023. * @returns a promsie that resolves when the operation is complete
  62024. */
  62025. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62026. /**
  62027. * Clones the raw cube texture.
  62028. * @return a new cube texture
  62029. */
  62030. clone(): CubeTexture;
  62031. /** @hidden */
  62032. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62033. }
  62034. }
  62035. declare module BABYLON {
  62036. /**
  62037. * Class used to store 2D array textures containing user data
  62038. */
  62039. export class RawTexture2DArray extends Texture {
  62040. /** Gets or sets the texture format to use */
  62041. format: number;
  62042. /**
  62043. * Create a new RawTexture2DArray
  62044. * @param data defines the data of the texture
  62045. * @param width defines the width of the texture
  62046. * @param height defines the height of the texture
  62047. * @param depth defines the number of layers of the texture
  62048. * @param format defines the texture format to use
  62049. * @param scene defines the hosting scene
  62050. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62051. * @param invertY defines if texture must be stored with Y axis inverted
  62052. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62053. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62054. */
  62055. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62056. /** Gets or sets the texture format to use */
  62057. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62058. /**
  62059. * Update the texture with new data
  62060. * @param data defines the data to store in the texture
  62061. */
  62062. update(data: ArrayBufferView): void;
  62063. }
  62064. }
  62065. declare module BABYLON {
  62066. /**
  62067. * Class used to store 3D textures containing user data
  62068. */
  62069. export class RawTexture3D extends Texture {
  62070. /** Gets or sets the texture format to use */
  62071. format: number;
  62072. /**
  62073. * Create a new RawTexture3D
  62074. * @param data defines the data of the texture
  62075. * @param width defines the width of the texture
  62076. * @param height defines the height of the texture
  62077. * @param depth defines the depth of the texture
  62078. * @param format defines the texture format to use
  62079. * @param scene defines the hosting scene
  62080. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62081. * @param invertY defines if texture must be stored with Y axis inverted
  62082. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62083. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62084. */
  62085. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62086. /** Gets or sets the texture format to use */
  62087. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62088. /**
  62089. * Update the texture with new data
  62090. * @param data defines the data to store in the texture
  62091. */
  62092. update(data: ArrayBufferView): void;
  62093. }
  62094. }
  62095. declare module BABYLON {
  62096. /**
  62097. * Creates a refraction texture used by refraction channel of the standard material.
  62098. * It is like a mirror but to see through a material.
  62099. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62100. */
  62101. export class RefractionTexture extends RenderTargetTexture {
  62102. /**
  62103. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62104. * 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.
  62105. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62106. */
  62107. refractionPlane: Plane;
  62108. /**
  62109. * Define how deep under the surface we should see.
  62110. */
  62111. depth: number;
  62112. /**
  62113. * Creates a refraction texture used by refraction channel of the standard material.
  62114. * It is like a mirror but to see through a material.
  62115. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62116. * @param name Define the texture name
  62117. * @param size Define the size of the underlying texture
  62118. * @param scene Define the scene the refraction belongs to
  62119. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62120. */
  62121. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62122. /**
  62123. * Clone the refraction texture.
  62124. * @returns the cloned texture
  62125. */
  62126. clone(): RefractionTexture;
  62127. /**
  62128. * Serialize the texture to a JSON representation you could use in Parse later on
  62129. * @returns the serialized JSON representation
  62130. */
  62131. serialize(): any;
  62132. }
  62133. }
  62134. declare module BABYLON {
  62135. /**
  62136. * Block used to add support for vertex skinning (bones)
  62137. */
  62138. export class BonesBlock extends NodeMaterialBlock {
  62139. /**
  62140. * Creates a new BonesBlock
  62141. * @param name defines the block name
  62142. */
  62143. constructor(name: string);
  62144. /**
  62145. * Initialize the block and prepare the context for build
  62146. * @param state defines the state that will be used for the build
  62147. */
  62148. initialize(state: NodeMaterialBuildState): void;
  62149. /**
  62150. * Gets the current class name
  62151. * @returns the class name
  62152. */
  62153. getClassName(): string;
  62154. /**
  62155. * Gets the matrix indices input component
  62156. */
  62157. get matricesIndices(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the matrix weights input component
  62160. */
  62161. get matricesWeights(): NodeMaterialConnectionPoint;
  62162. /**
  62163. * Gets the extra matrix indices input component
  62164. */
  62165. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62166. /**
  62167. * Gets the extra matrix weights input component
  62168. */
  62169. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62170. /**
  62171. * Gets the world input component
  62172. */
  62173. get world(): NodeMaterialConnectionPoint;
  62174. /**
  62175. * Gets the output component
  62176. */
  62177. get output(): NodeMaterialConnectionPoint;
  62178. autoConfigure(material: NodeMaterial): void;
  62179. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62182. protected _buildBlock(state: NodeMaterialBuildState): this;
  62183. }
  62184. }
  62185. declare module BABYLON {
  62186. /**
  62187. * Block used to add support for instances
  62188. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62189. */
  62190. export class InstancesBlock extends NodeMaterialBlock {
  62191. /**
  62192. * Creates a new InstancesBlock
  62193. * @param name defines the block name
  62194. */
  62195. constructor(name: string);
  62196. /**
  62197. * Gets the current class name
  62198. * @returns the class name
  62199. */
  62200. getClassName(): string;
  62201. /**
  62202. * Gets the first world row input component
  62203. */
  62204. get world0(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the second world row input component
  62207. */
  62208. get world1(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the third world row input component
  62211. */
  62212. get world2(): NodeMaterialConnectionPoint;
  62213. /**
  62214. * Gets the forth world row input component
  62215. */
  62216. get world3(): NodeMaterialConnectionPoint;
  62217. /**
  62218. * Gets the world input component
  62219. */
  62220. get world(): NodeMaterialConnectionPoint;
  62221. /**
  62222. * Gets the output component
  62223. */
  62224. get output(): NodeMaterialConnectionPoint;
  62225. /**
  62226. * Gets the isntanceID component
  62227. */
  62228. get instanceID(): NodeMaterialConnectionPoint;
  62229. autoConfigure(material: NodeMaterial): void;
  62230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62231. protected _buildBlock(state: NodeMaterialBuildState): this;
  62232. }
  62233. }
  62234. declare module BABYLON {
  62235. /**
  62236. * Block used to add morph targets support to vertex shader
  62237. */
  62238. export class MorphTargetsBlock extends NodeMaterialBlock {
  62239. private _repeatableContentAnchor;
  62240. /**
  62241. * Create a new MorphTargetsBlock
  62242. * @param name defines the block name
  62243. */
  62244. constructor(name: string);
  62245. /**
  62246. * Gets the current class name
  62247. * @returns the class name
  62248. */
  62249. getClassName(): string;
  62250. /**
  62251. * Gets the position input component
  62252. */
  62253. get position(): NodeMaterialConnectionPoint;
  62254. /**
  62255. * Gets the normal input component
  62256. */
  62257. get normal(): NodeMaterialConnectionPoint;
  62258. /**
  62259. * Gets the tangent input component
  62260. */
  62261. get tangent(): NodeMaterialConnectionPoint;
  62262. /**
  62263. * Gets the tangent input component
  62264. */
  62265. get uv(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the position output component
  62268. */
  62269. get positionOutput(): NodeMaterialConnectionPoint;
  62270. /**
  62271. * Gets the normal output component
  62272. */
  62273. get normalOutput(): NodeMaterialConnectionPoint;
  62274. /**
  62275. * Gets the tangent output component
  62276. */
  62277. get tangentOutput(): NodeMaterialConnectionPoint;
  62278. /**
  62279. * Gets the tangent output component
  62280. */
  62281. get uvOutput(): NodeMaterialConnectionPoint;
  62282. initialize(state: NodeMaterialBuildState): void;
  62283. autoConfigure(material: NodeMaterial): void;
  62284. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62285. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62286. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62287. protected _buildBlock(state: NodeMaterialBuildState): this;
  62288. }
  62289. }
  62290. declare module BABYLON {
  62291. /**
  62292. * Block used to get data information from a light
  62293. */
  62294. export class LightInformationBlock extends NodeMaterialBlock {
  62295. private _lightDataUniformName;
  62296. private _lightColorUniformName;
  62297. private _lightTypeDefineName;
  62298. /**
  62299. * Gets or sets the light associated with this block
  62300. */
  62301. light: Nullable<Light>;
  62302. /**
  62303. * Creates a new LightInformationBlock
  62304. * @param name defines the block name
  62305. */
  62306. constructor(name: string);
  62307. /**
  62308. * Gets the current class name
  62309. * @returns the class name
  62310. */
  62311. getClassName(): string;
  62312. /**
  62313. * Gets the world position input component
  62314. */
  62315. get worldPosition(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the direction output component
  62318. */
  62319. get direction(): NodeMaterialConnectionPoint;
  62320. /**
  62321. * Gets the direction output component
  62322. */
  62323. get color(): NodeMaterialConnectionPoint;
  62324. /**
  62325. * Gets the direction output component
  62326. */
  62327. get intensity(): NodeMaterialConnectionPoint;
  62328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62330. protected _buildBlock(state: NodeMaterialBuildState): this;
  62331. serialize(): any;
  62332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * Block used to add image processing support to fragment shader
  62338. */
  62339. export class ImageProcessingBlock extends NodeMaterialBlock {
  62340. /**
  62341. * Create a new ImageProcessingBlock
  62342. * @param name defines the block name
  62343. */
  62344. constructor(name: string);
  62345. /**
  62346. * Gets the current class name
  62347. * @returns the class name
  62348. */
  62349. getClassName(): string;
  62350. /**
  62351. * Gets the color input component
  62352. */
  62353. get color(): NodeMaterialConnectionPoint;
  62354. /**
  62355. * Gets the output component
  62356. */
  62357. get output(): NodeMaterialConnectionPoint;
  62358. /**
  62359. * Initialize the block and prepare the context for build
  62360. * @param state defines the state that will be used for the build
  62361. */
  62362. initialize(state: NodeMaterialBuildState): void;
  62363. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62365. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62366. protected _buildBlock(state: NodeMaterialBuildState): this;
  62367. }
  62368. }
  62369. declare module BABYLON {
  62370. /**
  62371. * Block used to pertub normals based on a normal map
  62372. */
  62373. export class PerturbNormalBlock extends NodeMaterialBlock {
  62374. private _tangentSpaceParameterName;
  62375. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62376. invertX: boolean;
  62377. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62378. invertY: boolean;
  62379. /**
  62380. * Create a new PerturbNormalBlock
  62381. * @param name defines the block name
  62382. */
  62383. constructor(name: string);
  62384. /**
  62385. * Gets the current class name
  62386. * @returns the class name
  62387. */
  62388. getClassName(): string;
  62389. /**
  62390. * Gets the world position input component
  62391. */
  62392. get worldPosition(): NodeMaterialConnectionPoint;
  62393. /**
  62394. * Gets the world normal input component
  62395. */
  62396. get worldNormal(): NodeMaterialConnectionPoint;
  62397. /**
  62398. * Gets the world tangent input component
  62399. */
  62400. get worldTangent(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the uv input component
  62403. */
  62404. get uv(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the normal map color input component
  62407. */
  62408. get normalMapColor(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the strength input component
  62411. */
  62412. get strength(): NodeMaterialConnectionPoint;
  62413. /**
  62414. * Gets the output component
  62415. */
  62416. get output(): NodeMaterialConnectionPoint;
  62417. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62418. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62419. autoConfigure(material: NodeMaterial): void;
  62420. protected _buildBlock(state: NodeMaterialBuildState): this;
  62421. protected _dumpPropertiesCode(): string;
  62422. serialize(): any;
  62423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62424. }
  62425. }
  62426. declare module BABYLON {
  62427. /**
  62428. * Block used to discard a pixel if a value is smaller than a cutoff
  62429. */
  62430. export class DiscardBlock extends NodeMaterialBlock {
  62431. /**
  62432. * Create a new DiscardBlock
  62433. * @param name defines the block name
  62434. */
  62435. constructor(name: string);
  62436. /**
  62437. * Gets the current class name
  62438. * @returns the class name
  62439. */
  62440. getClassName(): string;
  62441. /**
  62442. * Gets the color input component
  62443. */
  62444. get value(): NodeMaterialConnectionPoint;
  62445. /**
  62446. * Gets the cutoff input component
  62447. */
  62448. get cutoff(): NodeMaterialConnectionPoint;
  62449. protected _buildBlock(state: NodeMaterialBuildState): this;
  62450. }
  62451. }
  62452. declare module BABYLON {
  62453. /**
  62454. * Block used to test if the fragment shader is front facing
  62455. */
  62456. export class FrontFacingBlock extends NodeMaterialBlock {
  62457. /**
  62458. * Creates a new FrontFacingBlock
  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 output component
  62469. */
  62470. get output(): NodeMaterialConnectionPoint;
  62471. protected _buildBlock(state: NodeMaterialBuildState): this;
  62472. }
  62473. }
  62474. declare module BABYLON {
  62475. /**
  62476. * Block used to get the derivative value on x and y of a given input
  62477. */
  62478. export class DerivativeBlock extends NodeMaterialBlock {
  62479. /**
  62480. * Create a new DerivativeBlock
  62481. * @param name defines the block name
  62482. */
  62483. constructor(name: string);
  62484. /**
  62485. * Gets the current class name
  62486. * @returns the class name
  62487. */
  62488. getClassName(): string;
  62489. /**
  62490. * Gets the input component
  62491. */
  62492. get input(): NodeMaterialConnectionPoint;
  62493. /**
  62494. * Gets the derivative output on x
  62495. */
  62496. get dx(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the derivative output on y
  62499. */
  62500. get dy(): NodeMaterialConnectionPoint;
  62501. protected _buildBlock(state: NodeMaterialBuildState): this;
  62502. }
  62503. }
  62504. declare module BABYLON {
  62505. /**
  62506. * Block used to make gl_FragCoord available
  62507. */
  62508. export class FragCoordBlock extends NodeMaterialBlock {
  62509. /**
  62510. * Creates a new FragCoordBlock
  62511. * @param name defines the block name
  62512. */
  62513. constructor(name: string);
  62514. /**
  62515. * Gets the current class name
  62516. * @returns the class name
  62517. */
  62518. getClassName(): string;
  62519. /**
  62520. * Gets the xy component
  62521. */
  62522. get xy(): NodeMaterialConnectionPoint;
  62523. /**
  62524. * Gets the xyz component
  62525. */
  62526. get xyz(): NodeMaterialConnectionPoint;
  62527. /**
  62528. * Gets the xyzw component
  62529. */
  62530. get xyzw(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the x component
  62533. */
  62534. get x(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the y component
  62537. */
  62538. get y(): NodeMaterialConnectionPoint;
  62539. /**
  62540. * Gets the z component
  62541. */
  62542. get z(): NodeMaterialConnectionPoint;
  62543. /**
  62544. * Gets the w component
  62545. */
  62546. get output(): NodeMaterialConnectionPoint;
  62547. protected writeOutputs(state: NodeMaterialBuildState): string;
  62548. protected _buildBlock(state: NodeMaterialBuildState): this;
  62549. }
  62550. }
  62551. declare module BABYLON {
  62552. /**
  62553. * Block used to get the screen sizes
  62554. */
  62555. export class ScreenSizeBlock extends NodeMaterialBlock {
  62556. private _varName;
  62557. private _scene;
  62558. /**
  62559. * Creates a new ScreenSizeBlock
  62560. * @param name defines the block name
  62561. */
  62562. constructor(name: string);
  62563. /**
  62564. * Gets the current class name
  62565. * @returns the class name
  62566. */
  62567. getClassName(): string;
  62568. /**
  62569. * Gets the xy component
  62570. */
  62571. get xy(): NodeMaterialConnectionPoint;
  62572. /**
  62573. * Gets the x component
  62574. */
  62575. get x(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the y component
  62578. */
  62579. get y(): NodeMaterialConnectionPoint;
  62580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62581. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62582. protected _buildBlock(state: NodeMaterialBuildState): this;
  62583. }
  62584. }
  62585. declare module BABYLON {
  62586. /**
  62587. * Block used to add support for scene fog
  62588. */
  62589. export class FogBlock extends NodeMaterialBlock {
  62590. private _fogDistanceName;
  62591. private _fogParameters;
  62592. /**
  62593. * Create a new FogBlock
  62594. * @param name defines the block name
  62595. */
  62596. constructor(name: string);
  62597. /**
  62598. * Gets the current class name
  62599. * @returns the class name
  62600. */
  62601. getClassName(): string;
  62602. /**
  62603. * Gets the world position input component
  62604. */
  62605. get worldPosition(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the view input component
  62608. */
  62609. get view(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the color input component
  62612. */
  62613. get input(): NodeMaterialConnectionPoint;
  62614. /**
  62615. * Gets the fog color input component
  62616. */
  62617. get fogColor(): NodeMaterialConnectionPoint;
  62618. /**
  62619. * Gets the output component
  62620. */
  62621. get output(): NodeMaterialConnectionPoint;
  62622. autoConfigure(material: NodeMaterial): void;
  62623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62624. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62625. protected _buildBlock(state: NodeMaterialBuildState): this;
  62626. }
  62627. }
  62628. declare module BABYLON {
  62629. /**
  62630. * Block used to add light in the fragment shader
  62631. */
  62632. export class LightBlock extends NodeMaterialBlock {
  62633. private _lightId;
  62634. /**
  62635. * Gets or sets the light associated with this block
  62636. */
  62637. light: Nullable<Light>;
  62638. /**
  62639. * Create a new LightBlock
  62640. * @param name defines the block name
  62641. */
  62642. constructor(name: string);
  62643. /**
  62644. * Gets the current class name
  62645. * @returns the class name
  62646. */
  62647. getClassName(): string;
  62648. /**
  62649. * Gets the world position input component
  62650. */
  62651. get worldPosition(): NodeMaterialConnectionPoint;
  62652. /**
  62653. * Gets the world normal input component
  62654. */
  62655. get worldNormal(): NodeMaterialConnectionPoint;
  62656. /**
  62657. * Gets the camera (or eye) position component
  62658. */
  62659. get cameraPosition(): NodeMaterialConnectionPoint;
  62660. /**
  62661. * Gets the glossiness component
  62662. */
  62663. get glossiness(): NodeMaterialConnectionPoint;
  62664. /**
  62665. * Gets the glossinness power component
  62666. */
  62667. get glossPower(): NodeMaterialConnectionPoint;
  62668. /**
  62669. * Gets the diffuse color component
  62670. */
  62671. get diffuseColor(): NodeMaterialConnectionPoint;
  62672. /**
  62673. * Gets the specular color component
  62674. */
  62675. get specularColor(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the diffuse output component
  62678. */
  62679. get diffuseOutput(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the specular output component
  62682. */
  62683. get specularOutput(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the shadow output component
  62686. */
  62687. get shadow(): NodeMaterialConnectionPoint;
  62688. autoConfigure(material: NodeMaterial): void;
  62689. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62690. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62691. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62692. private _injectVertexCode;
  62693. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62694. serialize(): any;
  62695. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62696. }
  62697. }
  62698. declare module BABYLON {
  62699. /**
  62700. * Block used to read a reflection texture from a sampler
  62701. */
  62702. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62703. /**
  62704. * Create a new ReflectionTextureBlock
  62705. * @param name defines the block name
  62706. */
  62707. constructor(name: string);
  62708. /**
  62709. * Gets the current class name
  62710. * @returns the class name
  62711. */
  62712. getClassName(): string;
  62713. /**
  62714. * Gets the world position input component
  62715. */
  62716. get position(): NodeMaterialConnectionPoint;
  62717. /**
  62718. * Gets the world position input component
  62719. */
  62720. get worldPosition(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the world normal input component
  62723. */
  62724. get worldNormal(): NodeMaterialConnectionPoint;
  62725. /**
  62726. * Gets the world input component
  62727. */
  62728. get world(): NodeMaterialConnectionPoint;
  62729. /**
  62730. * Gets the camera (or eye) position component
  62731. */
  62732. get cameraPosition(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the view input component
  62735. */
  62736. get view(): NodeMaterialConnectionPoint;
  62737. /**
  62738. * Gets the rgb output component
  62739. */
  62740. get rgb(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the rgba output component
  62743. */
  62744. get rgba(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the r output component
  62747. */
  62748. get r(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the g output component
  62751. */
  62752. get g(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the b output component
  62755. */
  62756. get b(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the a output component
  62759. */
  62760. get a(): NodeMaterialConnectionPoint;
  62761. autoConfigure(material: NodeMaterial): void;
  62762. protected _buildBlock(state: NodeMaterialBuildState): this;
  62763. }
  62764. }
  62765. declare module BABYLON {
  62766. /**
  62767. * Block used to add 2 vectors
  62768. */
  62769. export class AddBlock extends NodeMaterialBlock {
  62770. /**
  62771. * Creates a new AddBlock
  62772. * @param name defines the block name
  62773. */
  62774. constructor(name: string);
  62775. /**
  62776. * Gets the current class name
  62777. * @returns the class name
  62778. */
  62779. getClassName(): string;
  62780. /**
  62781. * Gets the left operand input component
  62782. */
  62783. get left(): NodeMaterialConnectionPoint;
  62784. /**
  62785. * Gets the right operand input component
  62786. */
  62787. get right(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the output component
  62790. */
  62791. get output(): NodeMaterialConnectionPoint;
  62792. protected _buildBlock(state: NodeMaterialBuildState): this;
  62793. }
  62794. }
  62795. declare module BABYLON {
  62796. /**
  62797. * Block used to scale a vector by a float
  62798. */
  62799. export class ScaleBlock extends NodeMaterialBlock {
  62800. /**
  62801. * Creates a new ScaleBlock
  62802. * @param name defines the block name
  62803. */
  62804. constructor(name: string);
  62805. /**
  62806. * Gets the current class name
  62807. * @returns the class name
  62808. */
  62809. getClassName(): string;
  62810. /**
  62811. * Gets the input component
  62812. */
  62813. get input(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the factor input component
  62816. */
  62817. get factor(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the output component
  62820. */
  62821. get output(): NodeMaterialConnectionPoint;
  62822. protected _buildBlock(state: NodeMaterialBuildState): this;
  62823. }
  62824. }
  62825. declare module BABYLON {
  62826. /**
  62827. * Block used to clamp a float
  62828. */
  62829. export class ClampBlock extends NodeMaterialBlock {
  62830. /** Gets or sets the minimum range */
  62831. minimum: number;
  62832. /** Gets or sets the maximum range */
  62833. maximum: number;
  62834. /**
  62835. * Creates a new ClampBlock
  62836. * @param name defines the block name
  62837. */
  62838. constructor(name: string);
  62839. /**
  62840. * Gets the current class name
  62841. * @returns the class name
  62842. */
  62843. getClassName(): string;
  62844. /**
  62845. * Gets the value input component
  62846. */
  62847. get value(): NodeMaterialConnectionPoint;
  62848. /**
  62849. * Gets the output component
  62850. */
  62851. get output(): NodeMaterialConnectionPoint;
  62852. protected _buildBlock(state: NodeMaterialBuildState): this;
  62853. protected _dumpPropertiesCode(): string;
  62854. serialize(): any;
  62855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62856. }
  62857. }
  62858. declare module BABYLON {
  62859. /**
  62860. * Block used to apply a cross product between 2 vectors
  62861. */
  62862. export class CrossBlock extends NodeMaterialBlock {
  62863. /**
  62864. * Creates a new CrossBlock
  62865. * @param name defines the block name
  62866. */
  62867. constructor(name: string);
  62868. /**
  62869. * Gets the current class name
  62870. * @returns the class name
  62871. */
  62872. getClassName(): string;
  62873. /**
  62874. * Gets the left operand input component
  62875. */
  62876. get left(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the right operand input component
  62879. */
  62880. get right(): NodeMaterialConnectionPoint;
  62881. /**
  62882. * Gets the output component
  62883. */
  62884. get output(): NodeMaterialConnectionPoint;
  62885. protected _buildBlock(state: NodeMaterialBuildState): this;
  62886. }
  62887. }
  62888. declare module BABYLON {
  62889. /**
  62890. * Block used to apply a dot product between 2 vectors
  62891. */
  62892. export class DotBlock extends NodeMaterialBlock {
  62893. /**
  62894. * Creates a new DotBlock
  62895. * @param name defines the block name
  62896. */
  62897. constructor(name: string);
  62898. /**
  62899. * Gets the current class name
  62900. * @returns the class name
  62901. */
  62902. getClassName(): string;
  62903. /**
  62904. * Gets the left operand input component
  62905. */
  62906. get left(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the right operand input component
  62909. */
  62910. get right(): NodeMaterialConnectionPoint;
  62911. /**
  62912. * Gets the output component
  62913. */
  62914. get output(): NodeMaterialConnectionPoint;
  62915. protected _buildBlock(state: NodeMaterialBuildState): this;
  62916. }
  62917. }
  62918. declare module BABYLON {
  62919. /**
  62920. * Block used to normalize a vector
  62921. */
  62922. export class NormalizeBlock extends NodeMaterialBlock {
  62923. /**
  62924. * Creates a new NormalizeBlock
  62925. * @param name defines the block name
  62926. */
  62927. constructor(name: string);
  62928. /**
  62929. * Gets the current class name
  62930. * @returns the class name
  62931. */
  62932. getClassName(): string;
  62933. /**
  62934. * Gets the input component
  62935. */
  62936. get input(): NodeMaterialConnectionPoint;
  62937. /**
  62938. * Gets the output component
  62939. */
  62940. get output(): NodeMaterialConnectionPoint;
  62941. protected _buildBlock(state: NodeMaterialBuildState): this;
  62942. }
  62943. }
  62944. declare module BABYLON {
  62945. /**
  62946. * Operations supported by the Trigonometry block
  62947. */
  62948. export enum TrigonometryBlockOperations {
  62949. /** Cos */
  62950. Cos = 0,
  62951. /** Sin */
  62952. Sin = 1,
  62953. /** Abs */
  62954. Abs = 2,
  62955. /** Exp */
  62956. Exp = 3,
  62957. /** Exp2 */
  62958. Exp2 = 4,
  62959. /** Round */
  62960. Round = 5,
  62961. /** Floor */
  62962. Floor = 6,
  62963. /** Ceiling */
  62964. Ceiling = 7,
  62965. /** Square root */
  62966. Sqrt = 8,
  62967. /** Log */
  62968. Log = 9,
  62969. /** Tangent */
  62970. Tan = 10,
  62971. /** Arc tangent */
  62972. ArcTan = 11,
  62973. /** Arc cosinus */
  62974. ArcCos = 12,
  62975. /** Arc sinus */
  62976. ArcSin = 13,
  62977. /** Fraction */
  62978. Fract = 14,
  62979. /** Sign */
  62980. Sign = 15,
  62981. /** To radians (from degrees) */
  62982. Radians = 16,
  62983. /** To degrees (from radians) */
  62984. Degrees = 17
  62985. }
  62986. /**
  62987. * Block used to apply trigonometry operation to floats
  62988. */
  62989. export class TrigonometryBlock extends NodeMaterialBlock {
  62990. /**
  62991. * Gets or sets the operation applied by the block
  62992. */
  62993. operation: TrigonometryBlockOperations;
  62994. /**
  62995. * Creates a new TrigonometryBlock
  62996. * @param name defines the block name
  62997. */
  62998. constructor(name: string);
  62999. /**
  63000. * Gets the current class name
  63001. * @returns the class name
  63002. */
  63003. getClassName(): string;
  63004. /**
  63005. * Gets the input component
  63006. */
  63007. get input(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the output component
  63010. */
  63011. get output(): NodeMaterialConnectionPoint;
  63012. protected _buildBlock(state: NodeMaterialBuildState): this;
  63013. serialize(): any;
  63014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63015. protected _dumpPropertiesCode(): string;
  63016. }
  63017. }
  63018. declare module BABYLON {
  63019. /**
  63020. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63021. */
  63022. export class ColorMergerBlock extends NodeMaterialBlock {
  63023. /**
  63024. * Create a new ColorMergerBlock
  63025. * @param name defines the block name
  63026. */
  63027. constructor(name: string);
  63028. /**
  63029. * Gets the current class name
  63030. * @returns the class name
  63031. */
  63032. getClassName(): string;
  63033. /**
  63034. * Gets the rgb component (input)
  63035. */
  63036. get rgbIn(): NodeMaterialConnectionPoint;
  63037. /**
  63038. * Gets the r component (input)
  63039. */
  63040. get r(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the g component (input)
  63043. */
  63044. get g(): NodeMaterialConnectionPoint;
  63045. /**
  63046. * Gets the b component (input)
  63047. */
  63048. get b(): NodeMaterialConnectionPoint;
  63049. /**
  63050. * Gets the a component (input)
  63051. */
  63052. get a(): NodeMaterialConnectionPoint;
  63053. /**
  63054. * Gets the rgba component (output)
  63055. */
  63056. get rgba(): NodeMaterialConnectionPoint;
  63057. /**
  63058. * Gets the rgb component (output)
  63059. */
  63060. get rgbOut(): NodeMaterialConnectionPoint;
  63061. /**
  63062. * Gets the rgb component (output)
  63063. * @deprecated Please use rgbOut instead.
  63064. */
  63065. get rgb(): NodeMaterialConnectionPoint;
  63066. protected _buildBlock(state: NodeMaterialBuildState): this;
  63067. }
  63068. }
  63069. declare module BABYLON {
  63070. /**
  63071. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63072. */
  63073. export class VectorSplitterBlock extends NodeMaterialBlock {
  63074. /**
  63075. * Create a new VectorSplitterBlock
  63076. * @param name defines the block name
  63077. */
  63078. constructor(name: string);
  63079. /**
  63080. * Gets the current class name
  63081. * @returns the class name
  63082. */
  63083. getClassName(): string;
  63084. /**
  63085. * Gets the xyzw component (input)
  63086. */
  63087. get xyzw(): NodeMaterialConnectionPoint;
  63088. /**
  63089. * Gets the xyz component (input)
  63090. */
  63091. get xyzIn(): NodeMaterialConnectionPoint;
  63092. /**
  63093. * Gets the xy component (input)
  63094. */
  63095. get xyIn(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the xyz component (output)
  63098. */
  63099. get xyzOut(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the xy component (output)
  63102. */
  63103. get xyOut(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the x component (output)
  63106. */
  63107. get x(): NodeMaterialConnectionPoint;
  63108. /**
  63109. * Gets the y component (output)
  63110. */
  63111. get y(): NodeMaterialConnectionPoint;
  63112. /**
  63113. * Gets the z component (output)
  63114. */
  63115. get z(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the w component (output)
  63118. */
  63119. get w(): NodeMaterialConnectionPoint;
  63120. protected _inputRename(name: string): string;
  63121. protected _outputRename(name: string): string;
  63122. protected _buildBlock(state: NodeMaterialBuildState): this;
  63123. }
  63124. }
  63125. declare module BABYLON {
  63126. /**
  63127. * Block used to lerp between 2 values
  63128. */
  63129. export class LerpBlock extends NodeMaterialBlock {
  63130. /**
  63131. * Creates a new LerpBlock
  63132. * @param name defines the block name
  63133. */
  63134. constructor(name: string);
  63135. /**
  63136. * Gets the current class name
  63137. * @returns the class name
  63138. */
  63139. getClassName(): string;
  63140. /**
  63141. * Gets the left operand input component
  63142. */
  63143. get left(): NodeMaterialConnectionPoint;
  63144. /**
  63145. * Gets the right operand input component
  63146. */
  63147. get right(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the gradient operand input component
  63150. */
  63151. get gradient(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the output component
  63154. */
  63155. get output(): NodeMaterialConnectionPoint;
  63156. protected _buildBlock(state: NodeMaterialBuildState): this;
  63157. }
  63158. }
  63159. declare module BABYLON {
  63160. /**
  63161. * Block used to divide 2 vectors
  63162. */
  63163. export class DivideBlock extends NodeMaterialBlock {
  63164. /**
  63165. * Creates a new DivideBlock
  63166. * @param name defines the block name
  63167. */
  63168. constructor(name: string);
  63169. /**
  63170. * Gets the current class name
  63171. * @returns the class name
  63172. */
  63173. getClassName(): string;
  63174. /**
  63175. * Gets the left operand input component
  63176. */
  63177. get left(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the right operand input component
  63180. */
  63181. get right(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the output component
  63184. */
  63185. get output(): NodeMaterialConnectionPoint;
  63186. protected _buildBlock(state: NodeMaterialBuildState): this;
  63187. }
  63188. }
  63189. declare module BABYLON {
  63190. /**
  63191. * Block used to subtract 2 vectors
  63192. */
  63193. export class SubtractBlock extends NodeMaterialBlock {
  63194. /**
  63195. * Creates a new SubtractBlock
  63196. * @param name defines the block name
  63197. */
  63198. constructor(name: string);
  63199. /**
  63200. * Gets the current class name
  63201. * @returns the class name
  63202. */
  63203. getClassName(): string;
  63204. /**
  63205. * Gets the left operand input component
  63206. */
  63207. get left(): NodeMaterialConnectionPoint;
  63208. /**
  63209. * Gets the right operand input component
  63210. */
  63211. get right(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the output component
  63214. */
  63215. get output(): NodeMaterialConnectionPoint;
  63216. protected _buildBlock(state: NodeMaterialBuildState): this;
  63217. }
  63218. }
  63219. declare module BABYLON {
  63220. /**
  63221. * Block used to step a value
  63222. */
  63223. export class StepBlock extends NodeMaterialBlock {
  63224. /**
  63225. * Creates a new StepBlock
  63226. * @param name defines the block name
  63227. */
  63228. constructor(name: string);
  63229. /**
  63230. * Gets the current class name
  63231. * @returns the class name
  63232. */
  63233. getClassName(): string;
  63234. /**
  63235. * Gets the value operand input component
  63236. */
  63237. get value(): NodeMaterialConnectionPoint;
  63238. /**
  63239. * Gets the edge operand input component
  63240. */
  63241. get edge(): NodeMaterialConnectionPoint;
  63242. /**
  63243. * Gets the output component
  63244. */
  63245. get output(): NodeMaterialConnectionPoint;
  63246. protected _buildBlock(state: NodeMaterialBuildState): this;
  63247. }
  63248. }
  63249. declare module BABYLON {
  63250. /**
  63251. * Block used to get the opposite (1 - x) of a value
  63252. */
  63253. export class OneMinusBlock extends NodeMaterialBlock {
  63254. /**
  63255. * Creates a new OneMinusBlock
  63256. * @param name defines the block name
  63257. */
  63258. constructor(name: string);
  63259. /**
  63260. * Gets the current class name
  63261. * @returns the class name
  63262. */
  63263. getClassName(): string;
  63264. /**
  63265. * Gets the input component
  63266. */
  63267. get input(): NodeMaterialConnectionPoint;
  63268. /**
  63269. * Gets the output component
  63270. */
  63271. get output(): NodeMaterialConnectionPoint;
  63272. protected _buildBlock(state: NodeMaterialBuildState): this;
  63273. }
  63274. }
  63275. declare module BABYLON {
  63276. /**
  63277. * Block used to get the view direction
  63278. */
  63279. export class ViewDirectionBlock extends NodeMaterialBlock {
  63280. /**
  63281. * Creates a new ViewDirectionBlock
  63282. * @param name defines the block name
  63283. */
  63284. constructor(name: string);
  63285. /**
  63286. * Gets the current class name
  63287. * @returns the class name
  63288. */
  63289. getClassName(): string;
  63290. /**
  63291. * Gets the world position component
  63292. */
  63293. get worldPosition(): NodeMaterialConnectionPoint;
  63294. /**
  63295. * Gets the camera position component
  63296. */
  63297. get cameraPosition(): NodeMaterialConnectionPoint;
  63298. /**
  63299. * Gets the output component
  63300. */
  63301. get output(): NodeMaterialConnectionPoint;
  63302. autoConfigure(material: NodeMaterial): void;
  63303. protected _buildBlock(state: NodeMaterialBuildState): this;
  63304. }
  63305. }
  63306. declare module BABYLON {
  63307. /**
  63308. * Block used to compute fresnel value
  63309. */
  63310. export class FresnelBlock extends NodeMaterialBlock {
  63311. /**
  63312. * Create a new FresnelBlock
  63313. * @param name defines the block name
  63314. */
  63315. constructor(name: string);
  63316. /**
  63317. * Gets the current class name
  63318. * @returns the class name
  63319. */
  63320. getClassName(): string;
  63321. /**
  63322. * Gets the world normal input component
  63323. */
  63324. get worldNormal(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the view direction input component
  63327. */
  63328. get viewDirection(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the bias input component
  63331. */
  63332. get bias(): NodeMaterialConnectionPoint;
  63333. /**
  63334. * Gets the camera (or eye) position component
  63335. */
  63336. get power(): NodeMaterialConnectionPoint;
  63337. /**
  63338. * Gets the fresnel output component
  63339. */
  63340. get fresnel(): NodeMaterialConnectionPoint;
  63341. autoConfigure(material: NodeMaterial): void;
  63342. protected _buildBlock(state: NodeMaterialBuildState): this;
  63343. }
  63344. }
  63345. declare module BABYLON {
  63346. /**
  63347. * Block used to get the max of 2 values
  63348. */
  63349. export class MaxBlock extends NodeMaterialBlock {
  63350. /**
  63351. * Creates a new MaxBlock
  63352. * @param name defines the block name
  63353. */
  63354. constructor(name: string);
  63355. /**
  63356. * Gets the current class name
  63357. * @returns the class name
  63358. */
  63359. getClassName(): string;
  63360. /**
  63361. * Gets the left operand input component
  63362. */
  63363. get left(): NodeMaterialConnectionPoint;
  63364. /**
  63365. * Gets the right operand input component
  63366. */
  63367. get right(): NodeMaterialConnectionPoint;
  63368. /**
  63369. * Gets the output component
  63370. */
  63371. get output(): NodeMaterialConnectionPoint;
  63372. protected _buildBlock(state: NodeMaterialBuildState): this;
  63373. }
  63374. }
  63375. declare module BABYLON {
  63376. /**
  63377. * Block used to get the min of 2 values
  63378. */
  63379. export class MinBlock extends NodeMaterialBlock {
  63380. /**
  63381. * Creates a new MinBlock
  63382. * @param name defines the block name
  63383. */
  63384. constructor(name: string);
  63385. /**
  63386. * Gets the current class name
  63387. * @returns the class name
  63388. */
  63389. getClassName(): string;
  63390. /**
  63391. * Gets the left operand input component
  63392. */
  63393. get left(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the right operand input component
  63396. */
  63397. get right(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the output component
  63400. */
  63401. get output(): NodeMaterialConnectionPoint;
  63402. protected _buildBlock(state: NodeMaterialBuildState): this;
  63403. }
  63404. }
  63405. declare module BABYLON {
  63406. /**
  63407. * Block used to get the distance between 2 values
  63408. */
  63409. export class DistanceBlock extends NodeMaterialBlock {
  63410. /**
  63411. * Creates a new DistanceBlock
  63412. * @param name defines the block name
  63413. */
  63414. constructor(name: string);
  63415. /**
  63416. * Gets the current class name
  63417. * @returns the class name
  63418. */
  63419. getClassName(): string;
  63420. /**
  63421. * Gets the left operand input component
  63422. */
  63423. get left(): NodeMaterialConnectionPoint;
  63424. /**
  63425. * Gets the right operand input component
  63426. */
  63427. get right(): NodeMaterialConnectionPoint;
  63428. /**
  63429. * Gets the output component
  63430. */
  63431. get output(): NodeMaterialConnectionPoint;
  63432. protected _buildBlock(state: NodeMaterialBuildState): this;
  63433. }
  63434. }
  63435. declare module BABYLON {
  63436. /**
  63437. * Block used to get the length of a vector
  63438. */
  63439. export class LengthBlock extends NodeMaterialBlock {
  63440. /**
  63441. * Creates a new LengthBlock
  63442. * @param name defines the block name
  63443. */
  63444. constructor(name: string);
  63445. /**
  63446. * Gets the current class name
  63447. * @returns the class name
  63448. */
  63449. getClassName(): string;
  63450. /**
  63451. * Gets the value input component
  63452. */
  63453. get value(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the output component
  63456. */
  63457. get output(): NodeMaterialConnectionPoint;
  63458. protected _buildBlock(state: NodeMaterialBuildState): this;
  63459. }
  63460. }
  63461. declare module BABYLON {
  63462. /**
  63463. * Block used to get negative version of a value (i.e. x * -1)
  63464. */
  63465. export class NegateBlock extends NodeMaterialBlock {
  63466. /**
  63467. * Creates a new NegateBlock
  63468. * @param name defines the block name
  63469. */
  63470. constructor(name: string);
  63471. /**
  63472. * Gets the current class name
  63473. * @returns the class name
  63474. */
  63475. getClassName(): string;
  63476. /**
  63477. * Gets the value input component
  63478. */
  63479. get value(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the output component
  63482. */
  63483. get output(): NodeMaterialConnectionPoint;
  63484. protected _buildBlock(state: NodeMaterialBuildState): this;
  63485. }
  63486. }
  63487. declare module BABYLON {
  63488. /**
  63489. * Block used to get the value of the first parameter raised to the power of the second
  63490. */
  63491. export class PowBlock extends NodeMaterialBlock {
  63492. /**
  63493. * Creates a new PowBlock
  63494. * @param name defines the block name
  63495. */
  63496. constructor(name: string);
  63497. /**
  63498. * Gets the current class name
  63499. * @returns the class name
  63500. */
  63501. getClassName(): string;
  63502. /**
  63503. * Gets the value operand input component
  63504. */
  63505. get value(): NodeMaterialConnectionPoint;
  63506. /**
  63507. * Gets the power operand input component
  63508. */
  63509. get power(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the output component
  63512. */
  63513. get output(): NodeMaterialConnectionPoint;
  63514. protected _buildBlock(state: NodeMaterialBuildState): this;
  63515. }
  63516. }
  63517. declare module BABYLON {
  63518. /**
  63519. * Block used to get a random number
  63520. */
  63521. export class RandomNumberBlock extends NodeMaterialBlock {
  63522. /**
  63523. * Creates a new RandomNumberBlock
  63524. * @param name defines the block name
  63525. */
  63526. constructor(name: string);
  63527. /**
  63528. * Gets the current class name
  63529. * @returns the class name
  63530. */
  63531. getClassName(): string;
  63532. /**
  63533. * Gets the seed input component
  63534. */
  63535. get seed(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the output component
  63538. */
  63539. get output(): NodeMaterialConnectionPoint;
  63540. protected _buildBlock(state: NodeMaterialBuildState): this;
  63541. }
  63542. }
  63543. declare module BABYLON {
  63544. /**
  63545. * Block used to compute arc tangent of 2 values
  63546. */
  63547. export class ArcTan2Block extends NodeMaterialBlock {
  63548. /**
  63549. * Creates a new ArcTan2Block
  63550. * @param name defines the block name
  63551. */
  63552. constructor(name: string);
  63553. /**
  63554. * Gets the current class name
  63555. * @returns the class name
  63556. */
  63557. getClassName(): string;
  63558. /**
  63559. * Gets the x operand input component
  63560. */
  63561. get x(): NodeMaterialConnectionPoint;
  63562. /**
  63563. * Gets the y operand input component
  63564. */
  63565. get y(): NodeMaterialConnectionPoint;
  63566. /**
  63567. * Gets the output component
  63568. */
  63569. get output(): NodeMaterialConnectionPoint;
  63570. protected _buildBlock(state: NodeMaterialBuildState): this;
  63571. }
  63572. }
  63573. declare module BABYLON {
  63574. /**
  63575. * Block used to smooth step a value
  63576. */
  63577. export class SmoothStepBlock extends NodeMaterialBlock {
  63578. /**
  63579. * Creates a new SmoothStepBlock
  63580. * @param name defines the block name
  63581. */
  63582. constructor(name: string);
  63583. /**
  63584. * Gets the current class name
  63585. * @returns the class name
  63586. */
  63587. getClassName(): string;
  63588. /**
  63589. * Gets the value operand input component
  63590. */
  63591. get value(): NodeMaterialConnectionPoint;
  63592. /**
  63593. * Gets the first edge operand input component
  63594. */
  63595. get edge0(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the second edge operand input component
  63598. */
  63599. get edge1(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the output component
  63602. */
  63603. get output(): NodeMaterialConnectionPoint;
  63604. protected _buildBlock(state: NodeMaterialBuildState): this;
  63605. }
  63606. }
  63607. declare module BABYLON {
  63608. /**
  63609. * Block used to get the reciprocal (1 / x) of a value
  63610. */
  63611. export class ReciprocalBlock extends NodeMaterialBlock {
  63612. /**
  63613. * Creates a new ReciprocalBlock
  63614. * @param name defines the block name
  63615. */
  63616. constructor(name: string);
  63617. /**
  63618. * Gets the current class name
  63619. * @returns the class name
  63620. */
  63621. getClassName(): string;
  63622. /**
  63623. * Gets the input component
  63624. */
  63625. get input(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the output component
  63628. */
  63629. get output(): NodeMaterialConnectionPoint;
  63630. protected _buildBlock(state: NodeMaterialBuildState): this;
  63631. }
  63632. }
  63633. declare module BABYLON {
  63634. /**
  63635. * Block used to replace a color by another one
  63636. */
  63637. export class ReplaceColorBlock extends NodeMaterialBlock {
  63638. /**
  63639. * Creates a new ReplaceColorBlock
  63640. * @param name defines the block name
  63641. */
  63642. constructor(name: string);
  63643. /**
  63644. * Gets the current class name
  63645. * @returns the class name
  63646. */
  63647. getClassName(): string;
  63648. /**
  63649. * Gets the value input component
  63650. */
  63651. get value(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the reference input component
  63654. */
  63655. get reference(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Gets the distance input component
  63658. */
  63659. get distance(): NodeMaterialConnectionPoint;
  63660. /**
  63661. * Gets the replacement input component
  63662. */
  63663. get replacement(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the output component
  63666. */
  63667. get output(): NodeMaterialConnectionPoint;
  63668. protected _buildBlock(state: NodeMaterialBuildState): this;
  63669. }
  63670. }
  63671. declare module BABYLON {
  63672. /**
  63673. * Block used to posterize a value
  63674. * @see https://en.wikipedia.org/wiki/Posterization
  63675. */
  63676. export class PosterizeBlock extends NodeMaterialBlock {
  63677. /**
  63678. * Creates a new PosterizeBlock
  63679. * @param name defines the block name
  63680. */
  63681. constructor(name: string);
  63682. /**
  63683. * Gets the current class name
  63684. * @returns the class name
  63685. */
  63686. getClassName(): string;
  63687. /**
  63688. * Gets the value input component
  63689. */
  63690. get value(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the steps input component
  63693. */
  63694. get steps(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the output component
  63697. */
  63698. get output(): NodeMaterialConnectionPoint;
  63699. protected _buildBlock(state: NodeMaterialBuildState): this;
  63700. }
  63701. }
  63702. declare module BABYLON {
  63703. /**
  63704. * Operations supported by the Wave block
  63705. */
  63706. export enum WaveBlockKind {
  63707. /** SawTooth */
  63708. SawTooth = 0,
  63709. /** Square */
  63710. Square = 1,
  63711. /** Triangle */
  63712. Triangle = 2
  63713. }
  63714. /**
  63715. * Block used to apply wave operation to floats
  63716. */
  63717. export class WaveBlock extends NodeMaterialBlock {
  63718. /**
  63719. * Gets or sets the kibnd of wave to be applied by the block
  63720. */
  63721. kind: WaveBlockKind;
  63722. /**
  63723. * Creates a new WaveBlock
  63724. * @param name defines the block name
  63725. */
  63726. constructor(name: string);
  63727. /**
  63728. * Gets the current class name
  63729. * @returns the class name
  63730. */
  63731. getClassName(): string;
  63732. /**
  63733. * Gets the input component
  63734. */
  63735. get input(): NodeMaterialConnectionPoint;
  63736. /**
  63737. * Gets the output component
  63738. */
  63739. get output(): NodeMaterialConnectionPoint;
  63740. protected _buildBlock(state: NodeMaterialBuildState): this;
  63741. serialize(): any;
  63742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63743. }
  63744. }
  63745. declare module BABYLON {
  63746. /**
  63747. * Class used to store a color step for the GradientBlock
  63748. */
  63749. export class GradientBlockColorStep {
  63750. /**
  63751. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63752. */
  63753. step: number;
  63754. /**
  63755. * Gets or sets the color associated with this step
  63756. */
  63757. color: Color3;
  63758. /**
  63759. * Creates a new GradientBlockColorStep
  63760. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63761. * @param color defines the color associated with this step
  63762. */
  63763. constructor(
  63764. /**
  63765. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63766. */
  63767. step: number,
  63768. /**
  63769. * Gets or sets the color associated with this step
  63770. */
  63771. color: Color3);
  63772. }
  63773. /**
  63774. * Block used to return a color from a gradient based on an input value between 0 and 1
  63775. */
  63776. export class GradientBlock extends NodeMaterialBlock {
  63777. /**
  63778. * Gets or sets the list of color steps
  63779. */
  63780. colorSteps: GradientBlockColorStep[];
  63781. /**
  63782. * Creates a new GradientBlock
  63783. * @param name defines the block name
  63784. */
  63785. constructor(name: string);
  63786. /**
  63787. * Gets the current class name
  63788. * @returns the class name
  63789. */
  63790. getClassName(): string;
  63791. /**
  63792. * Gets the gradient input component
  63793. */
  63794. get gradient(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the output component
  63797. */
  63798. get output(): NodeMaterialConnectionPoint;
  63799. private _writeColorConstant;
  63800. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63801. serialize(): any;
  63802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63803. protected _dumpPropertiesCode(): string;
  63804. }
  63805. }
  63806. declare module BABYLON {
  63807. /**
  63808. * Block used to normalize lerp between 2 values
  63809. */
  63810. export class NLerpBlock extends NodeMaterialBlock {
  63811. /**
  63812. * Creates a new NLerpBlock
  63813. * @param name defines the block name
  63814. */
  63815. constructor(name: string);
  63816. /**
  63817. * Gets the current class name
  63818. * @returns the class name
  63819. */
  63820. getClassName(): string;
  63821. /**
  63822. * Gets the left operand input component
  63823. */
  63824. get left(): NodeMaterialConnectionPoint;
  63825. /**
  63826. * Gets the right operand input component
  63827. */
  63828. get right(): NodeMaterialConnectionPoint;
  63829. /**
  63830. * Gets the gradient operand input component
  63831. */
  63832. get gradient(): NodeMaterialConnectionPoint;
  63833. /**
  63834. * Gets the output component
  63835. */
  63836. get output(): NodeMaterialConnectionPoint;
  63837. protected _buildBlock(state: NodeMaterialBuildState): this;
  63838. }
  63839. }
  63840. declare module BABYLON {
  63841. /**
  63842. * block used to Generate a Worley Noise 3D Noise Pattern
  63843. */
  63844. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63845. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63846. manhattanDistance: boolean;
  63847. /**
  63848. * Creates a new WorleyNoise3DBlock
  63849. * @param name defines the block name
  63850. */
  63851. constructor(name: string);
  63852. /**
  63853. * Gets the current class name
  63854. * @returns the class name
  63855. */
  63856. getClassName(): string;
  63857. /**
  63858. * Gets the seed input component
  63859. */
  63860. get seed(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the jitter input component
  63863. */
  63864. get jitter(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the output component
  63867. */
  63868. get output(): NodeMaterialConnectionPoint;
  63869. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63870. /**
  63871. * Exposes the properties to the UI?
  63872. */
  63873. protected _dumpPropertiesCode(): string;
  63874. /**
  63875. * Exposes the properties to the Seralize?
  63876. */
  63877. serialize(): any;
  63878. /**
  63879. * Exposes the properties to the deseralize?
  63880. */
  63881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63882. }
  63883. }
  63884. declare module BABYLON {
  63885. /**
  63886. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63887. */
  63888. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63889. /**
  63890. * Creates a new SimplexPerlin3DBlock
  63891. * @param name defines the block name
  63892. */
  63893. constructor(name: string);
  63894. /**
  63895. * Gets the current class name
  63896. * @returns the class name
  63897. */
  63898. getClassName(): string;
  63899. /**
  63900. * Gets the seed operand input component
  63901. */
  63902. get seed(): NodeMaterialConnectionPoint;
  63903. /**
  63904. * Gets the output component
  63905. */
  63906. get output(): NodeMaterialConnectionPoint;
  63907. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63908. }
  63909. }
  63910. declare module BABYLON {
  63911. /**
  63912. * Block used to blend normals
  63913. */
  63914. export class NormalBlendBlock extends NodeMaterialBlock {
  63915. /**
  63916. * Creates a new NormalBlendBlock
  63917. * @param name defines the block name
  63918. */
  63919. constructor(name: string);
  63920. /**
  63921. * Gets the current class name
  63922. * @returns the class name
  63923. */
  63924. getClassName(): string;
  63925. /**
  63926. * Gets the first input component
  63927. */
  63928. get normalMap0(): NodeMaterialConnectionPoint;
  63929. /**
  63930. * Gets the second input component
  63931. */
  63932. get normalMap1(): NodeMaterialConnectionPoint;
  63933. /**
  63934. * Gets the output component
  63935. */
  63936. get output(): NodeMaterialConnectionPoint;
  63937. protected _buildBlock(state: NodeMaterialBuildState): this;
  63938. }
  63939. }
  63940. declare module BABYLON {
  63941. /**
  63942. * Block used to rotate a 2d vector by a given angle
  63943. */
  63944. export class Rotate2dBlock extends NodeMaterialBlock {
  63945. /**
  63946. * Creates a new Rotate2dBlock
  63947. * @param name defines the block name
  63948. */
  63949. constructor(name: string);
  63950. /**
  63951. * Gets the current class name
  63952. * @returns the class name
  63953. */
  63954. getClassName(): string;
  63955. /**
  63956. * Gets the input vector
  63957. */
  63958. get input(): NodeMaterialConnectionPoint;
  63959. /**
  63960. * Gets the input angle
  63961. */
  63962. get angle(): NodeMaterialConnectionPoint;
  63963. /**
  63964. * Gets the output component
  63965. */
  63966. get output(): NodeMaterialConnectionPoint;
  63967. autoConfigure(material: NodeMaterial): void;
  63968. protected _buildBlock(state: NodeMaterialBuildState): this;
  63969. }
  63970. }
  63971. declare module BABYLON {
  63972. /**
  63973. * Block used to get the reflected vector from a direction and a normal
  63974. */
  63975. export class ReflectBlock extends NodeMaterialBlock {
  63976. /**
  63977. * Creates a new ReflectBlock
  63978. * @param name defines the block name
  63979. */
  63980. constructor(name: string);
  63981. /**
  63982. * Gets the current class name
  63983. * @returns the class name
  63984. */
  63985. getClassName(): string;
  63986. /**
  63987. * Gets the incident component
  63988. */
  63989. get incident(): NodeMaterialConnectionPoint;
  63990. /**
  63991. * Gets the normal component
  63992. */
  63993. get normal(): NodeMaterialConnectionPoint;
  63994. /**
  63995. * Gets the output component
  63996. */
  63997. get output(): NodeMaterialConnectionPoint;
  63998. protected _buildBlock(state: NodeMaterialBuildState): this;
  63999. }
  64000. }
  64001. declare module BABYLON {
  64002. /**
  64003. * Block used to get the refracted vector from a direction and a normal
  64004. */
  64005. export class RefractBlock extends NodeMaterialBlock {
  64006. /**
  64007. * Creates a new RefractBlock
  64008. * @param name defines the block name
  64009. */
  64010. constructor(name: string);
  64011. /**
  64012. * Gets the current class name
  64013. * @returns the class name
  64014. */
  64015. getClassName(): string;
  64016. /**
  64017. * Gets the incident component
  64018. */
  64019. get incident(): NodeMaterialConnectionPoint;
  64020. /**
  64021. * Gets the normal component
  64022. */
  64023. get normal(): NodeMaterialConnectionPoint;
  64024. /**
  64025. * Gets the index of refraction component
  64026. */
  64027. get ior(): NodeMaterialConnectionPoint;
  64028. /**
  64029. * Gets the output component
  64030. */
  64031. get output(): NodeMaterialConnectionPoint;
  64032. protected _buildBlock(state: NodeMaterialBuildState): this;
  64033. }
  64034. }
  64035. declare module BABYLON {
  64036. /**
  64037. * Block used to desaturate a color
  64038. */
  64039. export class DesaturateBlock extends NodeMaterialBlock {
  64040. /**
  64041. * Creates a new DesaturateBlock
  64042. * @param name defines the block name
  64043. */
  64044. constructor(name: string);
  64045. /**
  64046. * Gets the current class name
  64047. * @returns the class name
  64048. */
  64049. getClassName(): string;
  64050. /**
  64051. * Gets the color operand input component
  64052. */
  64053. get color(): NodeMaterialConnectionPoint;
  64054. /**
  64055. * Gets the level operand input component
  64056. */
  64057. get level(): NodeMaterialConnectionPoint;
  64058. /**
  64059. * Gets the output component
  64060. */
  64061. get output(): NodeMaterialConnectionPoint;
  64062. protected _buildBlock(state: NodeMaterialBuildState): this;
  64063. }
  64064. }
  64065. declare module BABYLON {
  64066. /**
  64067. * Block used to implement the ambient occlusion module of the PBR material
  64068. */
  64069. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64070. /**
  64071. * Create a new AmbientOcclusionBlock
  64072. * @param name defines the block name
  64073. */
  64074. constructor(name: string);
  64075. /**
  64076. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64077. */
  64078. useAmbientInGrayScale: boolean;
  64079. /**
  64080. * Initialize the block and prepare the context for build
  64081. * @param state defines the state that will be used for the build
  64082. */
  64083. initialize(state: NodeMaterialBuildState): void;
  64084. /**
  64085. * Gets the current class name
  64086. * @returns the class name
  64087. */
  64088. getClassName(): string;
  64089. /**
  64090. * Gets the texture input component
  64091. */
  64092. get texture(): NodeMaterialConnectionPoint;
  64093. /**
  64094. * Gets the texture intensity component
  64095. */
  64096. get intensity(): NodeMaterialConnectionPoint;
  64097. /**
  64098. * Gets the direct light intensity input component
  64099. */
  64100. get directLightIntensity(): NodeMaterialConnectionPoint;
  64101. /**
  64102. * Gets the ambient occlusion object output component
  64103. */
  64104. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64105. /**
  64106. * Gets the main code of the block (fragment side)
  64107. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64108. * @returns the shader code
  64109. */
  64110. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64111. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64112. protected _buildBlock(state: NodeMaterialBuildState): this;
  64113. protected _dumpPropertiesCode(): string;
  64114. serialize(): any;
  64115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64116. }
  64117. }
  64118. declare module BABYLON {
  64119. /**
  64120. * Block used to implement the reflection module of the PBR material
  64121. */
  64122. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64123. /** @hidden */
  64124. _defineLODReflectionAlpha: string;
  64125. /** @hidden */
  64126. _defineLinearSpecularReflection: string;
  64127. private _vEnvironmentIrradianceName;
  64128. /** @hidden */
  64129. _vReflectionMicrosurfaceInfosName: string;
  64130. /** @hidden */
  64131. _vReflectionInfosName: string;
  64132. /** @hidden */
  64133. _vReflectionFilteringInfoName: string;
  64134. private _scene;
  64135. /**
  64136. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64137. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64138. * It's less burden on the user side in the editor part.
  64139. */
  64140. /** @hidden */
  64141. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64142. /** @hidden */
  64143. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64144. /** @hidden */
  64145. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64146. /**
  64147. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64148. * diffuse part of the IBL.
  64149. */
  64150. useSphericalHarmonics: boolean;
  64151. /**
  64152. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64153. */
  64154. forceIrradianceInFragment: boolean;
  64155. /**
  64156. * Create a new ReflectionBlock
  64157. * @param name defines the block name
  64158. */
  64159. constructor(name: string);
  64160. /**
  64161. * Gets the current class name
  64162. * @returns the class name
  64163. */
  64164. getClassName(): string;
  64165. /**
  64166. * Gets the position input component
  64167. */
  64168. get position(): NodeMaterialConnectionPoint;
  64169. /**
  64170. * Gets the world position input component
  64171. */
  64172. get worldPosition(): NodeMaterialConnectionPoint;
  64173. /**
  64174. * Gets the world normal input component
  64175. */
  64176. get worldNormal(): NodeMaterialConnectionPoint;
  64177. /**
  64178. * Gets the world input component
  64179. */
  64180. get world(): NodeMaterialConnectionPoint;
  64181. /**
  64182. * Gets the camera (or eye) position component
  64183. */
  64184. get cameraPosition(): NodeMaterialConnectionPoint;
  64185. /**
  64186. * Gets the view input component
  64187. */
  64188. get view(): NodeMaterialConnectionPoint;
  64189. /**
  64190. * Gets the color input component
  64191. */
  64192. get color(): NodeMaterialConnectionPoint;
  64193. /**
  64194. * Gets the reflection object output component
  64195. */
  64196. get reflection(): NodeMaterialConnectionPoint;
  64197. /**
  64198. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64199. */
  64200. get hasTexture(): boolean;
  64201. /**
  64202. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64203. */
  64204. get reflectionColor(): string;
  64205. protected _getTexture(): Nullable<BaseTexture>;
  64206. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64207. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64208. /**
  64209. * Gets the code to inject in the vertex shader
  64210. * @param state current state of the node material building
  64211. * @returns the shader code
  64212. */
  64213. handleVertexSide(state: NodeMaterialBuildState): string;
  64214. /**
  64215. * Gets the main code of the block (fragment side)
  64216. * @param state current state of the node material building
  64217. * @param normalVarName name of the existing variable corresponding to the normal
  64218. * @returns the shader code
  64219. */
  64220. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64221. protected _buildBlock(state: NodeMaterialBuildState): this;
  64222. protected _dumpPropertiesCode(): string;
  64223. serialize(): any;
  64224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64225. }
  64226. }
  64227. declare module BABYLON {
  64228. /**
  64229. * Block used to implement the sheen module of the PBR material
  64230. */
  64231. export class SheenBlock extends NodeMaterialBlock {
  64232. /**
  64233. * Create a new SheenBlock
  64234. * @param name defines the block name
  64235. */
  64236. constructor(name: string);
  64237. /**
  64238. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64239. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64240. * making it easier to setup and tweak the effect
  64241. */
  64242. albedoScaling: boolean;
  64243. /**
  64244. * Defines if the sheen is linked to the sheen color.
  64245. */
  64246. linkSheenWithAlbedo: boolean;
  64247. /**
  64248. * Initialize the block and prepare the context for build
  64249. * @param state defines the state that will be used for the build
  64250. */
  64251. initialize(state: NodeMaterialBuildState): void;
  64252. /**
  64253. * Gets the current class name
  64254. * @returns the class name
  64255. */
  64256. getClassName(): string;
  64257. /**
  64258. * Gets the intensity input component
  64259. */
  64260. get intensity(): NodeMaterialConnectionPoint;
  64261. /**
  64262. * Gets the color input component
  64263. */
  64264. get color(): NodeMaterialConnectionPoint;
  64265. /**
  64266. * Gets the roughness input component
  64267. */
  64268. get roughness(): NodeMaterialConnectionPoint;
  64269. /**
  64270. * Gets the sheen object output component
  64271. */
  64272. get sheen(): NodeMaterialConnectionPoint;
  64273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64274. /**
  64275. * Gets the main code of the block (fragment side)
  64276. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64277. * @returns the shader code
  64278. */
  64279. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64280. protected _buildBlock(state: NodeMaterialBuildState): this;
  64281. protected _dumpPropertiesCode(): string;
  64282. serialize(): any;
  64283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64284. }
  64285. }
  64286. declare module BABYLON {
  64287. /**
  64288. * Block used to implement the reflectivity module of the PBR material
  64289. */
  64290. export class ReflectivityBlock extends NodeMaterialBlock {
  64291. private _metallicReflectanceColor;
  64292. private _metallicF0Factor;
  64293. /** @hidden */
  64294. _vMetallicReflectanceFactorsName: string;
  64295. /**
  64296. * The property below is set by the main PBR block prior to calling methods of this class.
  64297. */
  64298. /** @hidden */
  64299. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64300. /**
  64301. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64302. */
  64303. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64304. /**
  64305. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64306. */
  64307. useMetallnessFromMetallicTextureBlue: boolean;
  64308. /**
  64309. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64310. */
  64311. useRoughnessFromMetallicTextureAlpha: boolean;
  64312. /**
  64313. * Specifies if the metallic texture contains the roughness information in its green channel.
  64314. */
  64315. useRoughnessFromMetallicTextureGreen: boolean;
  64316. /**
  64317. * Create a new ReflectivityBlock
  64318. * @param name defines the block name
  64319. */
  64320. constructor(name: string);
  64321. /**
  64322. * Initialize the block and prepare the context for build
  64323. * @param state defines the state that will be used for the build
  64324. */
  64325. initialize(state: NodeMaterialBuildState): void;
  64326. /**
  64327. * Gets the current class name
  64328. * @returns the class name
  64329. */
  64330. getClassName(): string;
  64331. /**
  64332. * Gets the metallic input component
  64333. */
  64334. get metallic(): NodeMaterialConnectionPoint;
  64335. /**
  64336. * Gets the roughness input component
  64337. */
  64338. get roughness(): NodeMaterialConnectionPoint;
  64339. /**
  64340. * Gets the texture input component
  64341. */
  64342. get texture(): NodeMaterialConnectionPoint;
  64343. /**
  64344. * Gets the reflectivity object output component
  64345. */
  64346. get reflectivity(): NodeMaterialConnectionPoint;
  64347. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64348. /**
  64349. * Gets the main code of the block (fragment side)
  64350. * @param state current state of the node material building
  64351. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64352. * @returns the shader code
  64353. */
  64354. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64356. protected _buildBlock(state: NodeMaterialBuildState): this;
  64357. protected _dumpPropertiesCode(): string;
  64358. serialize(): any;
  64359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64360. }
  64361. }
  64362. declare module BABYLON {
  64363. /**
  64364. * Block used to implement the anisotropy module of the PBR material
  64365. */
  64366. export class AnisotropyBlock extends NodeMaterialBlock {
  64367. /**
  64368. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64369. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64370. * It's less burden on the user side in the editor part.
  64371. */
  64372. /** @hidden */
  64373. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64374. /** @hidden */
  64375. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64376. /**
  64377. * Create a new AnisotropyBlock
  64378. * @param name defines the block name
  64379. */
  64380. constructor(name: string);
  64381. /**
  64382. * Initialize the block and prepare the context for build
  64383. * @param state defines the state that will be used for the build
  64384. */
  64385. initialize(state: NodeMaterialBuildState): void;
  64386. /**
  64387. * Gets the current class name
  64388. * @returns the class name
  64389. */
  64390. getClassName(): string;
  64391. /**
  64392. * Gets the intensity input component
  64393. */
  64394. get intensity(): NodeMaterialConnectionPoint;
  64395. /**
  64396. * Gets the direction input component
  64397. */
  64398. get direction(): NodeMaterialConnectionPoint;
  64399. /**
  64400. * Gets the texture input component
  64401. */
  64402. get texture(): NodeMaterialConnectionPoint;
  64403. /**
  64404. * Gets the uv input component
  64405. */
  64406. get uv(): NodeMaterialConnectionPoint;
  64407. /**
  64408. * Gets the worldTangent input component
  64409. */
  64410. get worldTangent(): NodeMaterialConnectionPoint;
  64411. /**
  64412. * Gets the anisotropy object output component
  64413. */
  64414. get anisotropy(): NodeMaterialConnectionPoint;
  64415. private _generateTBNSpace;
  64416. /**
  64417. * Gets the main code of the block (fragment side)
  64418. * @param state current state of the node material building
  64419. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64420. * @returns the shader code
  64421. */
  64422. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64424. protected _buildBlock(state: NodeMaterialBuildState): this;
  64425. }
  64426. }
  64427. declare module BABYLON {
  64428. /**
  64429. * Block used to implement the clear coat module of the PBR material
  64430. */
  64431. export class ClearCoatBlock extends NodeMaterialBlock {
  64432. private _scene;
  64433. /**
  64434. * Create a new ClearCoatBlock
  64435. * @param name defines the block name
  64436. */
  64437. constructor(name: string);
  64438. /**
  64439. * Initialize the block and prepare the context for build
  64440. * @param state defines the state that will be used for the build
  64441. */
  64442. initialize(state: NodeMaterialBuildState): void;
  64443. /**
  64444. * Gets the current class name
  64445. * @returns the class name
  64446. */
  64447. getClassName(): string;
  64448. /**
  64449. * Gets the intensity input component
  64450. */
  64451. get intensity(): NodeMaterialConnectionPoint;
  64452. /**
  64453. * Gets the roughness input component
  64454. */
  64455. get roughness(): NodeMaterialConnectionPoint;
  64456. /**
  64457. * Gets the ior input component
  64458. */
  64459. get ior(): NodeMaterialConnectionPoint;
  64460. /**
  64461. * Gets the texture input component
  64462. */
  64463. get texture(): NodeMaterialConnectionPoint;
  64464. /**
  64465. * Gets the bump texture input component
  64466. */
  64467. get bumpTexture(): NodeMaterialConnectionPoint;
  64468. /**
  64469. * Gets the uv input component
  64470. */
  64471. get uv(): NodeMaterialConnectionPoint;
  64472. /**
  64473. * Gets the tint color input component
  64474. */
  64475. get tintColor(): NodeMaterialConnectionPoint;
  64476. /**
  64477. * Gets the tint "at distance" input component
  64478. */
  64479. get tintAtDistance(): NodeMaterialConnectionPoint;
  64480. /**
  64481. * Gets the tint thickness input component
  64482. */
  64483. get tintThickness(): NodeMaterialConnectionPoint;
  64484. /**
  64485. * Gets the world tangent input component
  64486. */
  64487. get worldTangent(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the clear coat object output component
  64490. */
  64491. get clearcoat(): NodeMaterialConnectionPoint;
  64492. autoConfigure(material: NodeMaterial): void;
  64493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64495. private _generateTBNSpace;
  64496. /**
  64497. * Gets the main code of the block (fragment side)
  64498. * @param state current state of the node material building
  64499. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64500. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64501. * @param worldPosVarName name of the variable holding the world position
  64502. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64503. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64504. * @param worldNormalVarName name of the variable holding the world normal
  64505. * @returns the shader code
  64506. */
  64507. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64508. protected _buildBlock(state: NodeMaterialBuildState): this;
  64509. }
  64510. }
  64511. declare module BABYLON {
  64512. /**
  64513. * Block used to implement the sub surface module of the PBR material
  64514. */
  64515. export class SubSurfaceBlock extends NodeMaterialBlock {
  64516. /**
  64517. * Create a new SubSurfaceBlock
  64518. * @param name defines the block name
  64519. */
  64520. constructor(name: string);
  64521. /**
  64522. * Stores the intensity of the different subsurface effects in the thickness texture.
  64523. * * the green channel is the translucency intensity.
  64524. * * the blue channel is the scattering intensity.
  64525. * * the alpha channel is the refraction intensity.
  64526. */
  64527. useMaskFromThicknessTexture: boolean;
  64528. /**
  64529. * Initialize the block and prepare the context for build
  64530. * @param state defines the state that will be used for the build
  64531. */
  64532. initialize(state: NodeMaterialBuildState): void;
  64533. /**
  64534. * Gets the current class name
  64535. * @returns the class name
  64536. */
  64537. getClassName(): string;
  64538. /**
  64539. * Gets the min thickness input component
  64540. */
  64541. get minThickness(): NodeMaterialConnectionPoint;
  64542. /**
  64543. * Gets the max thickness input component
  64544. */
  64545. get maxThickness(): NodeMaterialConnectionPoint;
  64546. /**
  64547. * Gets the thickness texture component
  64548. */
  64549. get thicknessTexture(): NodeMaterialConnectionPoint;
  64550. /**
  64551. * Gets the tint color input component
  64552. */
  64553. get tintColor(): NodeMaterialConnectionPoint;
  64554. /**
  64555. * Gets the translucency intensity input component
  64556. */
  64557. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64558. /**
  64559. * Gets the translucency diffusion distance input component
  64560. */
  64561. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64562. /**
  64563. * Gets the refraction object parameters
  64564. */
  64565. get refraction(): NodeMaterialConnectionPoint;
  64566. /**
  64567. * Gets the sub surface object output component
  64568. */
  64569. get subsurface(): NodeMaterialConnectionPoint;
  64570. autoConfigure(material: NodeMaterial): void;
  64571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64572. /**
  64573. * Gets the main code of the block (fragment side)
  64574. * @param state current state of the node material building
  64575. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64576. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64577. * @param worldPosVarName name of the variable holding the world position
  64578. * @returns the shader code
  64579. */
  64580. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64581. protected _buildBlock(state: NodeMaterialBuildState): this;
  64582. }
  64583. }
  64584. declare module BABYLON {
  64585. /**
  64586. * Block used to implement the PBR metallic/roughness model
  64587. */
  64588. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64589. /**
  64590. * Gets or sets the light associated with this block
  64591. */
  64592. light: Nullable<Light>;
  64593. private _lightId;
  64594. private _scene;
  64595. private _environmentBRDFTexture;
  64596. private _environmentBrdfSamplerName;
  64597. private _vNormalWName;
  64598. private _invertNormalName;
  64599. /**
  64600. * Create a new ReflectionBlock
  64601. * @param name defines the block name
  64602. */
  64603. constructor(name: string);
  64604. /**
  64605. * Intensity of the direct lights e.g. the four lights available in your scene.
  64606. * This impacts both the direct diffuse and specular highlights.
  64607. */
  64608. directIntensity: number;
  64609. /**
  64610. * Intensity of the environment e.g. how much the environment will light the object
  64611. * either through harmonics for rough material or through the refelction for shiny ones.
  64612. */
  64613. environmentIntensity: number;
  64614. /**
  64615. * This is a special control allowing the reduction of the specular highlights coming from the
  64616. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64617. */
  64618. specularIntensity: number;
  64619. /**
  64620. * Defines the falloff type used in this material.
  64621. * It by default is Physical.
  64622. */
  64623. lightFalloff: number;
  64624. /**
  64625. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64626. */
  64627. useAlphaFromAlbedoTexture: boolean;
  64628. /**
  64629. * Specifies that alpha test should be used
  64630. */
  64631. useAlphaTest: boolean;
  64632. /**
  64633. * Defines the alpha limits in alpha test mode.
  64634. */
  64635. alphaTestCutoff: number;
  64636. /**
  64637. * Specifies that alpha blending should be used
  64638. */
  64639. useAlphaBlending: boolean;
  64640. /**
  64641. * Defines if the alpha value should be determined via the rgb values.
  64642. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64643. */
  64644. opacityRGB: boolean;
  64645. /**
  64646. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64647. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64648. */
  64649. useRadianceOverAlpha: boolean;
  64650. /**
  64651. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64652. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64653. */
  64654. useSpecularOverAlpha: boolean;
  64655. /**
  64656. * Enables specular anti aliasing in the PBR shader.
  64657. * It will both interacts on the Geometry for analytical and IBL lighting.
  64658. * It also prefilter the roughness map based on the bump values.
  64659. */
  64660. enableSpecularAntiAliasing: boolean;
  64661. /**
  64662. * Enables realtime filtering on the texture.
  64663. */
  64664. realTimeFiltering: boolean;
  64665. /**
  64666. * Quality switch for realtime filtering
  64667. */
  64668. realTimeFilteringQuality: number;
  64669. /**
  64670. * Defines if the material uses energy conservation.
  64671. */
  64672. useEnergyConservation: boolean;
  64673. /**
  64674. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64675. * too much the area relying on ambient texture to define their ambient occlusion.
  64676. */
  64677. useRadianceOcclusion: boolean;
  64678. /**
  64679. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64680. * makes the reflect vector face the model (under horizon).
  64681. */
  64682. useHorizonOcclusion: boolean;
  64683. /**
  64684. * If set to true, no lighting calculations will be applied.
  64685. */
  64686. unlit: boolean;
  64687. /**
  64688. * Force normal to face away from face.
  64689. */
  64690. forceNormalForward: boolean;
  64691. /**
  64692. * Defines the material debug mode.
  64693. * It helps seeing only some components of the material while troubleshooting.
  64694. */
  64695. debugMode: number;
  64696. /**
  64697. * Specify from where on screen the debug mode should start.
  64698. * The value goes from -1 (full screen) to 1 (not visible)
  64699. * It helps with side by side comparison against the final render
  64700. * This defaults to 0
  64701. */
  64702. debugLimit: number;
  64703. /**
  64704. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64705. * You can use the factor to better multiply the final value.
  64706. */
  64707. debugFactor: number;
  64708. /**
  64709. * Initialize the block and prepare the context for build
  64710. * @param state defines the state that will be used for the build
  64711. */
  64712. initialize(state: NodeMaterialBuildState): void;
  64713. /**
  64714. * Gets the current class name
  64715. * @returns the class name
  64716. */
  64717. getClassName(): string;
  64718. /**
  64719. * Gets the world position input component
  64720. */
  64721. get worldPosition(): NodeMaterialConnectionPoint;
  64722. /**
  64723. * Gets the world normal input component
  64724. */
  64725. get worldNormal(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the perturbed normal input component
  64728. */
  64729. get perturbedNormal(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the camera position input component
  64732. */
  64733. get cameraPosition(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the base color input component
  64736. */
  64737. get baseColor(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the opacity texture input component
  64740. */
  64741. get opacityTexture(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the ambient color input component
  64744. */
  64745. get ambientColor(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the reflectivity object parameters
  64748. */
  64749. get reflectivity(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the ambient occlusion object parameters
  64752. */
  64753. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the reflection object parameters
  64756. */
  64757. get reflection(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the sheen object parameters
  64760. */
  64761. get sheen(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the clear coat object parameters
  64764. */
  64765. get clearcoat(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the sub surface object parameters
  64768. */
  64769. get subsurface(): NodeMaterialConnectionPoint;
  64770. /**
  64771. * Gets the anisotropy object parameters
  64772. */
  64773. get anisotropy(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the ambient output component
  64776. */
  64777. get ambient(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the diffuse output component
  64780. */
  64781. get diffuse(): NodeMaterialConnectionPoint;
  64782. /**
  64783. * Gets the specular output component
  64784. */
  64785. get specular(): NodeMaterialConnectionPoint;
  64786. /**
  64787. * Gets the sheen output component
  64788. */
  64789. get sheenDir(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the clear coat output component
  64792. */
  64793. get clearcoatDir(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the indirect diffuse output component
  64796. */
  64797. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the indirect specular output component
  64800. */
  64801. get specularIndirect(): NodeMaterialConnectionPoint;
  64802. /**
  64803. * Gets the indirect sheen output component
  64804. */
  64805. get sheenIndirect(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the indirect clear coat output component
  64808. */
  64809. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the refraction output component
  64812. */
  64813. get refraction(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the global lighting output component
  64816. */
  64817. get lighting(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the shadow output component
  64820. */
  64821. get shadow(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the alpha output component
  64824. */
  64825. get alpha(): NodeMaterialConnectionPoint;
  64826. autoConfigure(material: NodeMaterial): void;
  64827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64828. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64830. private _injectVertexCode;
  64831. /**
  64832. * Gets the code corresponding to the albedo/opacity module
  64833. * @returns the shader code
  64834. */
  64835. getAlbedoOpacityCode(): string;
  64836. protected _buildBlock(state: NodeMaterialBuildState): this;
  64837. protected _dumpPropertiesCode(): string;
  64838. serialize(): any;
  64839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64840. }
  64841. }
  64842. declare module BABYLON {
  64843. /**
  64844. * Block used to compute value of one parameter modulo another
  64845. */
  64846. export class ModBlock extends NodeMaterialBlock {
  64847. /**
  64848. * Creates a new ModBlock
  64849. * @param name defines the block name
  64850. */
  64851. constructor(name: string);
  64852. /**
  64853. * Gets the current class name
  64854. * @returns the class name
  64855. */
  64856. getClassName(): string;
  64857. /**
  64858. * Gets the left operand input component
  64859. */
  64860. get left(): NodeMaterialConnectionPoint;
  64861. /**
  64862. * Gets the right operand input component
  64863. */
  64864. get right(): NodeMaterialConnectionPoint;
  64865. /**
  64866. * Gets the output component
  64867. */
  64868. get output(): NodeMaterialConnectionPoint;
  64869. protected _buildBlock(state: NodeMaterialBuildState): this;
  64870. }
  64871. }
  64872. declare module BABYLON {
  64873. /**
  64874. * Helper class to push actions to a pool of workers.
  64875. */
  64876. export class WorkerPool implements IDisposable {
  64877. private _workerInfos;
  64878. private _pendingActions;
  64879. /**
  64880. * Constructor
  64881. * @param workers Array of workers to use for actions
  64882. */
  64883. constructor(workers: Array<Worker>);
  64884. /**
  64885. * Terminates all workers and clears any pending actions.
  64886. */
  64887. dispose(): void;
  64888. /**
  64889. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64890. * pended until a worker has completed its action.
  64891. * @param action The action to perform. Call onComplete when the action is complete.
  64892. */
  64893. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64894. private _execute;
  64895. }
  64896. }
  64897. declare module BABYLON {
  64898. /**
  64899. * Configuration for Draco compression
  64900. */
  64901. export interface IDracoCompressionConfiguration {
  64902. /**
  64903. * Configuration for the decoder.
  64904. */
  64905. decoder: {
  64906. /**
  64907. * The url to the WebAssembly module.
  64908. */
  64909. wasmUrl?: string;
  64910. /**
  64911. * The url to the WebAssembly binary.
  64912. */
  64913. wasmBinaryUrl?: string;
  64914. /**
  64915. * The url to the fallback JavaScript module.
  64916. */
  64917. fallbackUrl?: string;
  64918. };
  64919. }
  64920. /**
  64921. * Draco compression (https://google.github.io/draco/)
  64922. *
  64923. * This class wraps the Draco module.
  64924. *
  64925. * **Encoder**
  64926. *
  64927. * The encoder is not currently implemented.
  64928. *
  64929. * **Decoder**
  64930. *
  64931. * 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.
  64932. *
  64933. * To update the configuration, use the following code:
  64934. * ```javascript
  64935. * DracoCompression.Configuration = {
  64936. * decoder: {
  64937. * wasmUrl: "<url to the WebAssembly library>",
  64938. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64939. * fallbackUrl: "<url to the fallback JavaScript library>",
  64940. * }
  64941. * };
  64942. * ```
  64943. *
  64944. * 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.
  64945. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64946. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64947. *
  64948. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64949. * ```javascript
  64950. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64951. * ```
  64952. *
  64953. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64954. */
  64955. export class DracoCompression implements IDisposable {
  64956. private _workerPoolPromise?;
  64957. private _decoderModulePromise?;
  64958. /**
  64959. * The configuration. Defaults to the following urls:
  64960. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64961. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64962. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64963. */
  64964. static Configuration: IDracoCompressionConfiguration;
  64965. /**
  64966. * Returns true if the decoder configuration is available.
  64967. */
  64968. static get DecoderAvailable(): boolean;
  64969. /**
  64970. * Default number of workers to create when creating the draco compression object.
  64971. */
  64972. static DefaultNumWorkers: number;
  64973. private static GetDefaultNumWorkers;
  64974. private static _Default;
  64975. /**
  64976. * Default instance for the draco compression object.
  64977. */
  64978. static get Default(): DracoCompression;
  64979. /**
  64980. * Constructor
  64981. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64982. */
  64983. constructor(numWorkers?: number);
  64984. /**
  64985. * Stop all async operations and release resources.
  64986. */
  64987. dispose(): void;
  64988. /**
  64989. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64990. * @returns a promise that resolves when ready
  64991. */
  64992. whenReadyAsync(): Promise<void>;
  64993. /**
  64994. * Decode Draco compressed mesh data to vertex data.
  64995. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64996. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64997. * @returns A promise that resolves with the decoded vertex data
  64998. */
  64999. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65000. [kind: string]: number;
  65001. }): Promise<VertexData>;
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * Class for building Constructive Solid Geometry
  65007. */
  65008. export class CSG {
  65009. private polygons;
  65010. /**
  65011. * The world matrix
  65012. */
  65013. matrix: Matrix;
  65014. /**
  65015. * Stores the position
  65016. */
  65017. position: Vector3;
  65018. /**
  65019. * Stores the rotation
  65020. */
  65021. rotation: Vector3;
  65022. /**
  65023. * Stores the rotation quaternion
  65024. */
  65025. rotationQuaternion: Nullable<Quaternion>;
  65026. /**
  65027. * Stores the scaling vector
  65028. */
  65029. scaling: Vector3;
  65030. /**
  65031. * Convert the Mesh to CSG
  65032. * @param mesh The Mesh to convert to CSG
  65033. * @returns A new CSG from the Mesh
  65034. */
  65035. static FromMesh(mesh: Mesh): CSG;
  65036. /**
  65037. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65038. * @param polygons Polygons used to construct a CSG solid
  65039. */
  65040. private static FromPolygons;
  65041. /**
  65042. * Clones, or makes a deep copy, of the CSG
  65043. * @returns A new CSG
  65044. */
  65045. clone(): CSG;
  65046. /**
  65047. * Unions this CSG with another CSG
  65048. * @param csg The CSG to union against this CSG
  65049. * @returns The unioned CSG
  65050. */
  65051. union(csg: CSG): CSG;
  65052. /**
  65053. * Unions this CSG with another CSG in place
  65054. * @param csg The CSG to union against this CSG
  65055. */
  65056. unionInPlace(csg: CSG): void;
  65057. /**
  65058. * Subtracts this CSG with another CSG
  65059. * @param csg The CSG to subtract against this CSG
  65060. * @returns A new CSG
  65061. */
  65062. subtract(csg: CSG): CSG;
  65063. /**
  65064. * Subtracts this CSG with another CSG in place
  65065. * @param csg The CSG to subtact against this CSG
  65066. */
  65067. subtractInPlace(csg: CSG): void;
  65068. /**
  65069. * Intersect this CSG with another CSG
  65070. * @param csg The CSG to intersect against this CSG
  65071. * @returns A new CSG
  65072. */
  65073. intersect(csg: CSG): CSG;
  65074. /**
  65075. * Intersects this CSG with another CSG in place
  65076. * @param csg The CSG to intersect against this CSG
  65077. */
  65078. intersectInPlace(csg: CSG): void;
  65079. /**
  65080. * Return a new CSG solid with solid and empty space switched. This solid is
  65081. * not modified.
  65082. * @returns A new CSG solid with solid and empty space switched
  65083. */
  65084. inverse(): CSG;
  65085. /**
  65086. * Inverses the CSG in place
  65087. */
  65088. inverseInPlace(): void;
  65089. /**
  65090. * This is used to keep meshes transformations so they can be restored
  65091. * when we build back a Babylon Mesh
  65092. * NB : All CSG operations are performed in world coordinates
  65093. * @param csg The CSG to copy the transform attributes from
  65094. * @returns This CSG
  65095. */
  65096. copyTransformAttributes(csg: CSG): CSG;
  65097. /**
  65098. * Build Raw mesh from CSG
  65099. * Coordinates here are in world space
  65100. * @param name The name of the mesh geometry
  65101. * @param scene The Scene
  65102. * @param keepSubMeshes Specifies if the submeshes should be kept
  65103. * @returns A new Mesh
  65104. */
  65105. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65106. /**
  65107. * Build Mesh from CSG taking material and transforms into account
  65108. * @param name The name of the Mesh
  65109. * @param material The material of the Mesh
  65110. * @param scene The Scene
  65111. * @param keepSubMeshes Specifies if submeshes should be kept
  65112. * @returns The new Mesh
  65113. */
  65114. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65115. }
  65116. }
  65117. declare module BABYLON {
  65118. /**
  65119. * Class used to create a trail following a mesh
  65120. */
  65121. export class TrailMesh extends Mesh {
  65122. private _generator;
  65123. private _autoStart;
  65124. private _running;
  65125. private _diameter;
  65126. private _length;
  65127. private _sectionPolygonPointsCount;
  65128. private _sectionVectors;
  65129. private _sectionNormalVectors;
  65130. private _beforeRenderObserver;
  65131. /**
  65132. * @constructor
  65133. * @param name The value used by scene.getMeshByName() to do a lookup.
  65134. * @param generator The mesh or transform node to generate a trail.
  65135. * @param scene The scene to add this mesh to.
  65136. * @param diameter Diameter of trailing mesh. Default is 1.
  65137. * @param length Length of trailing mesh. Default is 60.
  65138. * @param autoStart Automatically start trailing mesh. Default true.
  65139. */
  65140. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65141. /**
  65142. * "TrailMesh"
  65143. * @returns "TrailMesh"
  65144. */
  65145. getClassName(): string;
  65146. private _createMesh;
  65147. /**
  65148. * Start trailing mesh.
  65149. */
  65150. start(): void;
  65151. /**
  65152. * Stop trailing mesh.
  65153. */
  65154. stop(): void;
  65155. /**
  65156. * Update trailing mesh geometry.
  65157. */
  65158. update(): void;
  65159. /**
  65160. * Returns a new TrailMesh object.
  65161. * @param name is a string, the name given to the new mesh
  65162. * @param newGenerator use new generator object for cloned trail mesh
  65163. * @returns a new mesh
  65164. */
  65165. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65166. /**
  65167. * Serializes this trail mesh
  65168. * @param serializationObject object to write serialization to
  65169. */
  65170. serialize(serializationObject: any): void;
  65171. /**
  65172. * Parses a serialized trail mesh
  65173. * @param parsedMesh the serialized mesh
  65174. * @param scene the scene to create the trail mesh in
  65175. * @returns the created trail mesh
  65176. */
  65177. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65178. }
  65179. }
  65180. declare module BABYLON {
  65181. /**
  65182. * Class containing static functions to help procedurally build meshes
  65183. */
  65184. export class TiledBoxBuilder {
  65185. /**
  65186. * Creates a box mesh
  65187. * 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)
  65188. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65190. * * 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
  65191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65192. * @param name defines the name of the mesh
  65193. * @param options defines the options used to create the mesh
  65194. * @param scene defines the hosting scene
  65195. * @returns the box mesh
  65196. */
  65197. static CreateTiledBox(name: string, options: {
  65198. pattern?: number;
  65199. width?: number;
  65200. height?: number;
  65201. depth?: number;
  65202. tileSize?: number;
  65203. tileWidth?: number;
  65204. tileHeight?: number;
  65205. alignHorizontal?: number;
  65206. alignVertical?: number;
  65207. faceUV?: Vector4[];
  65208. faceColors?: Color4[];
  65209. sideOrientation?: number;
  65210. updatable?: boolean;
  65211. }, scene?: Nullable<Scene>): Mesh;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /**
  65216. * Class containing static functions to help procedurally build meshes
  65217. */
  65218. export class TorusKnotBuilder {
  65219. /**
  65220. * Creates a torus knot mesh
  65221. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65222. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65223. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65224. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65226. * * 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
  65227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65228. * @param name defines the name of the mesh
  65229. * @param options defines the options used to create the mesh
  65230. * @param scene defines the hosting scene
  65231. * @returns the torus knot mesh
  65232. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65233. */
  65234. static CreateTorusKnot(name: string, options: {
  65235. radius?: number;
  65236. tube?: number;
  65237. radialSegments?: number;
  65238. tubularSegments?: number;
  65239. p?: number;
  65240. q?: number;
  65241. updatable?: boolean;
  65242. sideOrientation?: number;
  65243. frontUVs?: Vector4;
  65244. backUVs?: Vector4;
  65245. }, scene: any): Mesh;
  65246. }
  65247. }
  65248. declare module BABYLON {
  65249. /**
  65250. * Polygon
  65251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65252. */
  65253. export class Polygon {
  65254. /**
  65255. * Creates a rectangle
  65256. * @param xmin bottom X coord
  65257. * @param ymin bottom Y coord
  65258. * @param xmax top X coord
  65259. * @param ymax top Y coord
  65260. * @returns points that make the resulting rectation
  65261. */
  65262. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65263. /**
  65264. * Creates a circle
  65265. * @param radius radius of circle
  65266. * @param cx scale in x
  65267. * @param cy scale in y
  65268. * @param numberOfSides number of sides that make up the circle
  65269. * @returns points that make the resulting circle
  65270. */
  65271. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65272. /**
  65273. * Creates a polygon from input string
  65274. * @param input Input polygon data
  65275. * @returns the parsed points
  65276. */
  65277. static Parse(input: string): Vector2[];
  65278. /**
  65279. * Starts building a polygon from x and y coordinates
  65280. * @param x x coordinate
  65281. * @param y y coordinate
  65282. * @returns the started path2
  65283. */
  65284. static StartingAt(x: number, y: number): Path2;
  65285. }
  65286. /**
  65287. * Builds a polygon
  65288. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65289. */
  65290. export class PolygonMeshBuilder {
  65291. private _points;
  65292. private _outlinepoints;
  65293. private _holes;
  65294. private _name;
  65295. private _scene;
  65296. private _epoints;
  65297. private _eholes;
  65298. private _addToepoint;
  65299. /**
  65300. * Babylon reference to the earcut plugin.
  65301. */
  65302. bjsEarcut: any;
  65303. /**
  65304. * Creates a PolygonMeshBuilder
  65305. * @param name name of the builder
  65306. * @param contours Path of the polygon
  65307. * @param scene scene to add to when creating the mesh
  65308. * @param earcutInjection can be used to inject your own earcut reference
  65309. */
  65310. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65311. /**
  65312. * Adds a whole within the polygon
  65313. * @param hole Array of points defining the hole
  65314. * @returns this
  65315. */
  65316. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65317. /**
  65318. * Creates the polygon
  65319. * @param updatable If the mesh should be updatable
  65320. * @param depth The depth of the mesh created
  65321. * @returns the created mesh
  65322. */
  65323. build(updatable?: boolean, depth?: number): Mesh;
  65324. /**
  65325. * Creates the polygon
  65326. * @param depth The depth of the mesh created
  65327. * @returns the created VertexData
  65328. */
  65329. buildVertexData(depth?: number): VertexData;
  65330. /**
  65331. * Adds a side to the polygon
  65332. * @param positions points that make the polygon
  65333. * @param normals normals of the polygon
  65334. * @param uvs uvs of the polygon
  65335. * @param indices indices of the polygon
  65336. * @param bounds bounds of the polygon
  65337. * @param points points of the polygon
  65338. * @param depth depth of the polygon
  65339. * @param flip flip of the polygon
  65340. */
  65341. private addSide;
  65342. }
  65343. }
  65344. declare module BABYLON {
  65345. /**
  65346. * Class containing static functions to help procedurally build meshes
  65347. */
  65348. export class PolygonBuilder {
  65349. /**
  65350. * Creates a polygon mesh
  65351. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65352. * * 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
  65353. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65355. * * 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)
  65356. * * Remember you can only change the shape positions, not their number when updating a polygon
  65357. * @param name defines the name of the mesh
  65358. * @param options defines the options used to create the mesh
  65359. * @param scene defines the hosting scene
  65360. * @param earcutInjection can be used to inject your own earcut reference
  65361. * @returns the polygon mesh
  65362. */
  65363. static CreatePolygon(name: string, options: {
  65364. shape: Vector3[];
  65365. holes?: Vector3[][];
  65366. depth?: number;
  65367. faceUV?: Vector4[];
  65368. faceColors?: Color4[];
  65369. updatable?: boolean;
  65370. sideOrientation?: number;
  65371. frontUVs?: Vector4;
  65372. backUVs?: Vector4;
  65373. wrap?: boolean;
  65374. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65375. /**
  65376. * Creates an extruded polygon mesh, with depth in the Y direction.
  65377. * * 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)
  65378. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65379. * @param name defines the name of the mesh
  65380. * @param options defines the options used to create the mesh
  65381. * @param scene defines the hosting scene
  65382. * @param earcutInjection can be used to inject your own earcut reference
  65383. * @returns the polygon mesh
  65384. */
  65385. static ExtrudePolygon(name: string, options: {
  65386. shape: Vector3[];
  65387. holes?: Vector3[][];
  65388. depth?: number;
  65389. faceUV?: Vector4[];
  65390. faceColors?: Color4[];
  65391. updatable?: boolean;
  65392. sideOrientation?: number;
  65393. frontUVs?: Vector4;
  65394. backUVs?: Vector4;
  65395. wrap?: boolean;
  65396. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65397. }
  65398. }
  65399. declare module BABYLON {
  65400. /**
  65401. * Class containing static functions to help procedurally build meshes
  65402. */
  65403. export class LatheBuilder {
  65404. /**
  65405. * Creates lathe mesh.
  65406. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65407. * * 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
  65408. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65409. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65410. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65411. * * 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
  65412. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65413. * * 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
  65414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65415. * * 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
  65416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65418. * @param name defines the name of the mesh
  65419. * @param options defines the options used to create the mesh
  65420. * @param scene defines the hosting scene
  65421. * @returns the lathe mesh
  65422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65423. */
  65424. static CreateLathe(name: string, options: {
  65425. shape: Vector3[];
  65426. radius?: number;
  65427. tessellation?: number;
  65428. clip?: number;
  65429. arc?: number;
  65430. closed?: boolean;
  65431. updatable?: boolean;
  65432. sideOrientation?: number;
  65433. frontUVs?: Vector4;
  65434. backUVs?: Vector4;
  65435. cap?: number;
  65436. invertUV?: boolean;
  65437. }, scene?: Nullable<Scene>): Mesh;
  65438. }
  65439. }
  65440. declare module BABYLON {
  65441. /**
  65442. * Class containing static functions to help procedurally build meshes
  65443. */
  65444. export class TiledPlaneBuilder {
  65445. /**
  65446. * Creates a tiled plane mesh
  65447. * * The parameter `pattern` will, depending on value, do nothing or
  65448. * * * flip (reflect about central vertical) alternate tiles across and up
  65449. * * * flip every tile on alternate rows
  65450. * * * rotate (180 degs) alternate tiles across and up
  65451. * * * rotate every tile on alternate rows
  65452. * * * flip and rotate alternate tiles across and up
  65453. * * * flip and rotate every tile on alternate rows
  65454. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65455. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65456. * * 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
  65457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65458. * * 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)
  65459. * * 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)
  65460. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65461. * @param name defines the name of the mesh
  65462. * @param options defines the options used to create the mesh
  65463. * @param scene defines the hosting scene
  65464. * @returns the box mesh
  65465. */
  65466. static CreateTiledPlane(name: string, options: {
  65467. pattern?: number;
  65468. tileSize?: number;
  65469. tileWidth?: number;
  65470. tileHeight?: number;
  65471. size?: number;
  65472. width?: number;
  65473. height?: number;
  65474. alignHorizontal?: number;
  65475. alignVertical?: number;
  65476. sideOrientation?: number;
  65477. frontUVs?: Vector4;
  65478. backUVs?: Vector4;
  65479. updatable?: boolean;
  65480. }, scene?: Nullable<Scene>): Mesh;
  65481. }
  65482. }
  65483. declare module BABYLON {
  65484. /**
  65485. * Class containing static functions to help procedurally build meshes
  65486. */
  65487. export class TubeBuilder {
  65488. /**
  65489. * Creates a tube mesh.
  65490. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65491. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65492. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65493. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65494. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65495. * * 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)
  65496. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65497. * * 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
  65498. * * 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
  65499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65500. * * 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
  65501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65503. * @param name defines the name of the mesh
  65504. * @param options defines the options used to create the mesh
  65505. * @param scene defines the hosting scene
  65506. * @returns the tube mesh
  65507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65508. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65509. */
  65510. static CreateTube(name: string, options: {
  65511. path: Vector3[];
  65512. radius?: number;
  65513. tessellation?: number;
  65514. radiusFunction?: {
  65515. (i: number, distance: number): number;
  65516. };
  65517. cap?: number;
  65518. arc?: number;
  65519. updatable?: boolean;
  65520. sideOrientation?: number;
  65521. frontUVs?: Vector4;
  65522. backUVs?: Vector4;
  65523. instance?: Mesh;
  65524. invertUV?: boolean;
  65525. }, scene?: Nullable<Scene>): Mesh;
  65526. }
  65527. }
  65528. declare module BABYLON {
  65529. /**
  65530. * Class containing static functions to help procedurally build meshes
  65531. */
  65532. export class IcoSphereBuilder {
  65533. /**
  65534. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65535. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65536. * * 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`)
  65537. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65538. * * 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
  65539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65540. * * 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
  65541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65542. * @param name defines the name of the mesh
  65543. * @param options defines the options used to create the mesh
  65544. * @param scene defines the hosting scene
  65545. * @returns the icosahedron mesh
  65546. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65547. */
  65548. static CreateIcoSphere(name: string, options: {
  65549. radius?: number;
  65550. radiusX?: number;
  65551. radiusY?: number;
  65552. radiusZ?: number;
  65553. flat?: boolean;
  65554. subdivisions?: number;
  65555. sideOrientation?: number;
  65556. frontUVs?: Vector4;
  65557. backUVs?: Vector4;
  65558. updatable?: boolean;
  65559. }, scene?: Nullable<Scene>): Mesh;
  65560. }
  65561. }
  65562. declare module BABYLON {
  65563. /**
  65564. * Class containing static functions to help procedurally build meshes
  65565. */
  65566. export class DecalBuilder {
  65567. /**
  65568. * Creates a decal mesh.
  65569. * 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
  65570. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65571. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65572. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65573. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65574. * @param name defines the name of the mesh
  65575. * @param sourceMesh defines the mesh where the decal must be applied
  65576. * @param options defines the options used to create the mesh
  65577. * @param scene defines the hosting scene
  65578. * @returns the decal mesh
  65579. * @see https://doc.babylonjs.com/how_to/decals
  65580. */
  65581. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65582. position?: Vector3;
  65583. normal?: Vector3;
  65584. size?: Vector3;
  65585. angle?: number;
  65586. }): Mesh;
  65587. }
  65588. }
  65589. declare module BABYLON {
  65590. /**
  65591. * Class containing static functions to help procedurally build meshes
  65592. */
  65593. export class MeshBuilder {
  65594. /**
  65595. * Creates a box mesh
  65596. * * The parameter `size` sets the size (float) of each box side (default 1)
  65597. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65598. * * 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)
  65599. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65601. * * 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
  65602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65603. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65604. * @param name defines the name of the mesh
  65605. * @param options defines the options used to create the mesh
  65606. * @param scene defines the hosting scene
  65607. * @returns the box mesh
  65608. */
  65609. static CreateBox(name: string, options: {
  65610. size?: number;
  65611. width?: number;
  65612. height?: number;
  65613. depth?: number;
  65614. faceUV?: Vector4[];
  65615. faceColors?: Color4[];
  65616. sideOrientation?: number;
  65617. frontUVs?: Vector4;
  65618. backUVs?: Vector4;
  65619. wrap?: boolean;
  65620. topBaseAt?: number;
  65621. bottomBaseAt?: number;
  65622. updatable?: boolean;
  65623. }, scene?: Nullable<Scene>): Mesh;
  65624. /**
  65625. * Creates a tiled box mesh
  65626. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65628. * @param name defines the name of the mesh
  65629. * @param options defines the options used to create the mesh
  65630. * @param scene defines the hosting scene
  65631. * @returns the tiled box mesh
  65632. */
  65633. static CreateTiledBox(name: string, options: {
  65634. pattern?: number;
  65635. size?: number;
  65636. width?: number;
  65637. height?: number;
  65638. depth: number;
  65639. tileSize?: number;
  65640. tileWidth?: number;
  65641. tileHeight?: number;
  65642. faceUV?: Vector4[];
  65643. faceColors?: Color4[];
  65644. alignHorizontal?: number;
  65645. alignVertical?: number;
  65646. sideOrientation?: number;
  65647. updatable?: boolean;
  65648. }, scene?: Nullable<Scene>): Mesh;
  65649. /**
  65650. * Creates a sphere mesh
  65651. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65652. * * 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`)
  65653. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65654. * * 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
  65655. * * 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)
  65656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65657. * * 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
  65658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65659. * @param name defines the name of the mesh
  65660. * @param options defines the options used to create the mesh
  65661. * @param scene defines the hosting scene
  65662. * @returns the sphere mesh
  65663. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65664. */
  65665. static CreateSphere(name: string, options: {
  65666. segments?: number;
  65667. diameter?: number;
  65668. diameterX?: number;
  65669. diameterY?: number;
  65670. diameterZ?: number;
  65671. arc?: number;
  65672. slice?: number;
  65673. sideOrientation?: number;
  65674. frontUVs?: Vector4;
  65675. backUVs?: Vector4;
  65676. updatable?: boolean;
  65677. }, scene?: Nullable<Scene>): Mesh;
  65678. /**
  65679. * Creates a plane polygonal mesh. By default, this is a disc
  65680. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65681. * * 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
  65682. * * 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
  65683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65684. * * 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
  65685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65686. * @param name defines the name of the mesh
  65687. * @param options defines the options used to create the mesh
  65688. * @param scene defines the hosting scene
  65689. * @returns the plane polygonal mesh
  65690. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65691. */
  65692. static CreateDisc(name: string, options: {
  65693. radius?: number;
  65694. tessellation?: number;
  65695. arc?: number;
  65696. updatable?: boolean;
  65697. sideOrientation?: number;
  65698. frontUVs?: Vector4;
  65699. backUVs?: Vector4;
  65700. }, scene?: Nullable<Scene>): Mesh;
  65701. /**
  65702. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65703. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65704. * * 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`)
  65705. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65706. * * 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
  65707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65708. * * 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
  65709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65710. * @param name defines the name of the mesh
  65711. * @param options defines the options used to create the mesh
  65712. * @param scene defines the hosting scene
  65713. * @returns the icosahedron mesh
  65714. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65715. */
  65716. static CreateIcoSphere(name: string, options: {
  65717. radius?: number;
  65718. radiusX?: number;
  65719. radiusY?: number;
  65720. radiusZ?: number;
  65721. flat?: boolean;
  65722. subdivisions?: number;
  65723. sideOrientation?: number;
  65724. frontUVs?: Vector4;
  65725. backUVs?: Vector4;
  65726. updatable?: boolean;
  65727. }, scene?: Nullable<Scene>): Mesh;
  65728. /**
  65729. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65730. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65731. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65732. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65733. * * 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
  65734. * * 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
  65735. * * 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
  65736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65737. * * 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
  65738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65739. * * 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
  65740. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65741. * * 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
  65742. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65744. * @param name defines the name of the mesh
  65745. * @param options defines the options used to create the mesh
  65746. * @param scene defines the hosting scene
  65747. * @returns the ribbon mesh
  65748. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65749. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65750. */
  65751. static CreateRibbon(name: string, options: {
  65752. pathArray: Vector3[][];
  65753. closeArray?: boolean;
  65754. closePath?: boolean;
  65755. offset?: number;
  65756. updatable?: boolean;
  65757. sideOrientation?: number;
  65758. frontUVs?: Vector4;
  65759. backUVs?: Vector4;
  65760. instance?: Mesh;
  65761. invertUV?: boolean;
  65762. uvs?: Vector2[];
  65763. colors?: Color4[];
  65764. }, scene?: Nullable<Scene>): Mesh;
  65765. /**
  65766. * Creates a cylinder or a cone mesh
  65767. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65768. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65769. * * 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.
  65770. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65771. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65772. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65773. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65774. * * 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).
  65775. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65776. * * 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).
  65777. * * 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
  65778. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65779. * * 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
  65780. * * 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.
  65781. * * If `enclose` is false, a ring surface is one element.
  65782. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65783. * * 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
  65784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65785. * * 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
  65786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65787. * @param name defines the name of the mesh
  65788. * @param options defines the options used to create the mesh
  65789. * @param scene defines the hosting scene
  65790. * @returns the cylinder mesh
  65791. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65792. */
  65793. static CreateCylinder(name: string, options: {
  65794. height?: number;
  65795. diameterTop?: number;
  65796. diameterBottom?: number;
  65797. diameter?: number;
  65798. tessellation?: number;
  65799. subdivisions?: number;
  65800. arc?: number;
  65801. faceColors?: Color4[];
  65802. faceUV?: Vector4[];
  65803. updatable?: boolean;
  65804. hasRings?: boolean;
  65805. enclose?: boolean;
  65806. cap?: number;
  65807. sideOrientation?: number;
  65808. frontUVs?: Vector4;
  65809. backUVs?: Vector4;
  65810. }, scene?: Nullable<Scene>): Mesh;
  65811. /**
  65812. * Creates a torus mesh
  65813. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65814. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65815. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65817. * * 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
  65818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65819. * @param name defines the name of the mesh
  65820. * @param options defines the options used to create the mesh
  65821. * @param scene defines the hosting scene
  65822. * @returns the torus mesh
  65823. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65824. */
  65825. static CreateTorus(name: string, options: {
  65826. diameter?: number;
  65827. thickness?: number;
  65828. tessellation?: number;
  65829. updatable?: boolean;
  65830. sideOrientation?: number;
  65831. frontUVs?: Vector4;
  65832. backUVs?: Vector4;
  65833. }, scene?: Nullable<Scene>): Mesh;
  65834. /**
  65835. * Creates a torus knot mesh
  65836. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65837. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65838. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65839. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65841. * * 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
  65842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65843. * @param name defines the name of the mesh
  65844. * @param options defines the options used to create the mesh
  65845. * @param scene defines the hosting scene
  65846. * @returns the torus knot mesh
  65847. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65848. */
  65849. static CreateTorusKnot(name: string, options: {
  65850. radius?: number;
  65851. tube?: number;
  65852. radialSegments?: number;
  65853. tubularSegments?: number;
  65854. p?: number;
  65855. q?: number;
  65856. updatable?: boolean;
  65857. sideOrientation?: number;
  65858. frontUVs?: Vector4;
  65859. backUVs?: Vector4;
  65860. }, scene?: Nullable<Scene>): Mesh;
  65861. /**
  65862. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65863. * * 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
  65864. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65865. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65866. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65867. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65868. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65869. * * 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
  65870. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65872. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65873. * @param name defines the name of the new line system
  65874. * @param options defines the options used to create the line system
  65875. * @param scene defines the hosting scene
  65876. * @returns a new line system mesh
  65877. */
  65878. static CreateLineSystem(name: string, options: {
  65879. lines: Vector3[][];
  65880. updatable?: boolean;
  65881. instance?: Nullable<LinesMesh>;
  65882. colors?: Nullable<Color4[][]>;
  65883. useVertexAlpha?: boolean;
  65884. }, scene: Nullable<Scene>): LinesMesh;
  65885. /**
  65886. * Creates a line mesh
  65887. * 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
  65888. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65889. * * The parameter `points` is an array successive Vector3
  65890. * * 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
  65891. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65892. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65893. * * When updating an instance, remember that only point positions can change, not the number of points
  65894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65896. * @param name defines the name of the new line system
  65897. * @param options defines the options used to create the line system
  65898. * @param scene defines the hosting scene
  65899. * @returns a new line mesh
  65900. */
  65901. static CreateLines(name: string, options: {
  65902. points: Vector3[];
  65903. updatable?: boolean;
  65904. instance?: Nullable<LinesMesh>;
  65905. colors?: Color4[];
  65906. useVertexAlpha?: boolean;
  65907. }, scene?: Nullable<Scene>): LinesMesh;
  65908. /**
  65909. * Creates a dashed line mesh
  65910. * * 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
  65911. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65912. * * The parameter `points` is an array successive Vector3
  65913. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65914. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65915. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65916. * * 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
  65917. * * When updating an instance, remember that only point positions can change, not the number of points
  65918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65919. * @param name defines the name of the mesh
  65920. * @param options defines the options used to create the mesh
  65921. * @param scene defines the hosting scene
  65922. * @returns the dashed line mesh
  65923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65924. */
  65925. static CreateDashedLines(name: string, options: {
  65926. points: Vector3[];
  65927. dashSize?: number;
  65928. gapSize?: number;
  65929. dashNb?: number;
  65930. updatable?: boolean;
  65931. instance?: LinesMesh;
  65932. }, scene?: Nullable<Scene>): LinesMesh;
  65933. /**
  65934. * 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.
  65935. * * 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.
  65936. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65937. * * 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.
  65938. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65939. * * 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
  65940. * * 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
  65941. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65943. * * 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
  65944. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65946. * @param name defines the name of the mesh
  65947. * @param options defines the options used to create the mesh
  65948. * @param scene defines the hosting scene
  65949. * @returns the extruded shape mesh
  65950. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65952. */
  65953. static ExtrudeShape(name: string, options: {
  65954. shape: Vector3[];
  65955. path: Vector3[];
  65956. scale?: number;
  65957. rotation?: number;
  65958. cap?: number;
  65959. updatable?: boolean;
  65960. sideOrientation?: number;
  65961. frontUVs?: Vector4;
  65962. backUVs?: Vector4;
  65963. instance?: Mesh;
  65964. invertUV?: boolean;
  65965. }, scene?: Nullable<Scene>): Mesh;
  65966. /**
  65967. * Creates an custom extruded shape mesh.
  65968. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65969. * * 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.
  65970. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65971. * * 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
  65972. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65973. * * 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
  65974. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65975. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65976. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65977. * * 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
  65978. * * 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
  65979. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65981. * * 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
  65982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65984. * @param name defines the name of the mesh
  65985. * @param options defines the options used to create the mesh
  65986. * @param scene defines the hosting scene
  65987. * @returns the custom extruded shape mesh
  65988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65989. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65991. */
  65992. static ExtrudeShapeCustom(name: string, options: {
  65993. shape: Vector3[];
  65994. path: Vector3[];
  65995. scaleFunction?: any;
  65996. rotationFunction?: any;
  65997. ribbonCloseArray?: boolean;
  65998. ribbonClosePath?: boolean;
  65999. cap?: number;
  66000. updatable?: boolean;
  66001. sideOrientation?: number;
  66002. frontUVs?: Vector4;
  66003. backUVs?: Vector4;
  66004. instance?: Mesh;
  66005. invertUV?: boolean;
  66006. }, scene?: Nullable<Scene>): Mesh;
  66007. /**
  66008. * Creates lathe mesh.
  66009. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66010. * * 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
  66011. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66012. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66013. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66014. * * 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
  66015. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66016. * * 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
  66017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66018. * * 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
  66019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66021. * @param name defines the name of the mesh
  66022. * @param options defines the options used to create the mesh
  66023. * @param scene defines the hosting scene
  66024. * @returns the lathe mesh
  66025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66026. */
  66027. static CreateLathe(name: string, options: {
  66028. shape: Vector3[];
  66029. radius?: number;
  66030. tessellation?: number;
  66031. clip?: number;
  66032. arc?: number;
  66033. closed?: boolean;
  66034. updatable?: boolean;
  66035. sideOrientation?: number;
  66036. frontUVs?: Vector4;
  66037. backUVs?: Vector4;
  66038. cap?: number;
  66039. invertUV?: boolean;
  66040. }, scene?: Nullable<Scene>): Mesh;
  66041. /**
  66042. * Creates a tiled plane mesh
  66043. * * You can set a limited pattern arrangement with the tiles
  66044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66045. * * 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
  66046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66047. * @param name defines the name of the mesh
  66048. * @param options defines the options used to create the mesh
  66049. * @param scene defines the hosting scene
  66050. * @returns the plane mesh
  66051. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66052. */
  66053. static CreateTiledPlane(name: string, options: {
  66054. pattern?: number;
  66055. tileSize?: number;
  66056. tileWidth?: number;
  66057. tileHeight?: number;
  66058. size?: number;
  66059. width?: number;
  66060. height?: number;
  66061. alignHorizontal?: number;
  66062. alignVertical?: number;
  66063. sideOrientation?: number;
  66064. frontUVs?: Vector4;
  66065. backUVs?: Vector4;
  66066. updatable?: boolean;
  66067. }, scene?: Nullable<Scene>): Mesh;
  66068. /**
  66069. * Creates a plane mesh
  66070. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66071. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66072. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66074. * * 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
  66075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66076. * @param name defines the name of the mesh
  66077. * @param options defines the options used to create the mesh
  66078. * @param scene defines the hosting scene
  66079. * @returns the plane mesh
  66080. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66081. */
  66082. static CreatePlane(name: string, options: {
  66083. size?: number;
  66084. width?: number;
  66085. height?: number;
  66086. sideOrientation?: number;
  66087. frontUVs?: Vector4;
  66088. backUVs?: Vector4;
  66089. updatable?: boolean;
  66090. sourcePlane?: Plane;
  66091. }, scene?: Nullable<Scene>): Mesh;
  66092. /**
  66093. * Creates a ground mesh
  66094. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66095. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66097. * @param name defines the name of the mesh
  66098. * @param options defines the options used to create the mesh
  66099. * @param scene defines the hosting scene
  66100. * @returns the ground mesh
  66101. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66102. */
  66103. static CreateGround(name: string, options: {
  66104. width?: number;
  66105. height?: number;
  66106. subdivisions?: number;
  66107. subdivisionsX?: number;
  66108. subdivisionsY?: number;
  66109. updatable?: boolean;
  66110. }, scene?: Nullable<Scene>): Mesh;
  66111. /**
  66112. * Creates a tiled ground mesh
  66113. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66114. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66115. * * 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
  66116. * * 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
  66117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66118. * @param name defines the name of the mesh
  66119. * @param options defines the options used to create the mesh
  66120. * @param scene defines the hosting scene
  66121. * @returns the tiled ground mesh
  66122. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66123. */
  66124. static CreateTiledGround(name: string, options: {
  66125. xmin: number;
  66126. zmin: number;
  66127. xmax: number;
  66128. zmax: number;
  66129. subdivisions?: {
  66130. w: number;
  66131. h: number;
  66132. };
  66133. precision?: {
  66134. w: number;
  66135. h: number;
  66136. };
  66137. updatable?: boolean;
  66138. }, scene?: Nullable<Scene>): Mesh;
  66139. /**
  66140. * Creates a ground mesh from a height map
  66141. * * The parameter `url` sets the URL of the height map image resource.
  66142. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66143. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66144. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66145. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66146. * * 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.
  66147. * * 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).
  66148. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66150. * @param name defines the name of the mesh
  66151. * @param url defines the url to the height map
  66152. * @param options defines the options used to create the mesh
  66153. * @param scene defines the hosting scene
  66154. * @returns the ground mesh
  66155. * @see https://doc.babylonjs.com/babylon101/height_map
  66156. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66157. */
  66158. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66159. width?: number;
  66160. height?: number;
  66161. subdivisions?: number;
  66162. minHeight?: number;
  66163. maxHeight?: number;
  66164. colorFilter?: Color3;
  66165. alphaFilter?: number;
  66166. updatable?: boolean;
  66167. onReady?: (mesh: GroundMesh) => void;
  66168. }, scene?: Nullable<Scene>): GroundMesh;
  66169. /**
  66170. * Creates a polygon mesh
  66171. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66172. * * 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
  66173. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66175. * * 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)
  66176. * * Remember you can only change the shape positions, not their number when updating a polygon
  66177. * @param name defines the name of the mesh
  66178. * @param options defines the options used to create the mesh
  66179. * @param scene defines the hosting scene
  66180. * @param earcutInjection can be used to inject your own earcut reference
  66181. * @returns the polygon mesh
  66182. */
  66183. static CreatePolygon(name: string, options: {
  66184. shape: Vector3[];
  66185. holes?: Vector3[][];
  66186. depth?: number;
  66187. faceUV?: Vector4[];
  66188. faceColors?: Color4[];
  66189. updatable?: boolean;
  66190. sideOrientation?: number;
  66191. frontUVs?: Vector4;
  66192. backUVs?: Vector4;
  66193. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66194. /**
  66195. * Creates an extruded polygon mesh, with depth in the Y direction.
  66196. * * 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)
  66197. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66198. * @param name defines the name of the mesh
  66199. * @param options defines the options used to create the mesh
  66200. * @param scene defines the hosting scene
  66201. * @param earcutInjection can be used to inject your own earcut reference
  66202. * @returns the polygon mesh
  66203. */
  66204. static ExtrudePolygon(name: string, options: {
  66205. shape: Vector3[];
  66206. holes?: Vector3[][];
  66207. depth?: number;
  66208. faceUV?: Vector4[];
  66209. faceColors?: Color4[];
  66210. updatable?: boolean;
  66211. sideOrientation?: number;
  66212. frontUVs?: Vector4;
  66213. backUVs?: Vector4;
  66214. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66215. /**
  66216. * Creates a tube mesh.
  66217. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66218. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66219. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66220. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66221. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66222. * * 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)
  66223. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66224. * * 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
  66225. * * 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
  66226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66227. * * 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
  66228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66230. * @param name defines the name of the mesh
  66231. * @param options defines the options used to create the mesh
  66232. * @param scene defines the hosting scene
  66233. * @returns the tube mesh
  66234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66235. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66236. */
  66237. static CreateTube(name: string, options: {
  66238. path: Vector3[];
  66239. radius?: number;
  66240. tessellation?: number;
  66241. radiusFunction?: {
  66242. (i: number, distance: number): number;
  66243. };
  66244. cap?: number;
  66245. arc?: number;
  66246. updatable?: boolean;
  66247. sideOrientation?: number;
  66248. frontUVs?: Vector4;
  66249. backUVs?: Vector4;
  66250. instance?: Mesh;
  66251. invertUV?: boolean;
  66252. }, scene?: Nullable<Scene>): Mesh;
  66253. /**
  66254. * Creates a polyhedron mesh
  66255. * * 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
  66256. * * The parameter `size` (positive float, default 1) sets the polygon size
  66257. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66258. * * 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`
  66259. * * 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
  66260. * * 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)`)
  66261. * * 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
  66262. * * 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
  66263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66264. * * 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
  66265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66266. * @param name defines the name of the mesh
  66267. * @param options defines the options used to create the mesh
  66268. * @param scene defines the hosting scene
  66269. * @returns the polyhedron mesh
  66270. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66271. */
  66272. static CreatePolyhedron(name: string, options: {
  66273. type?: number;
  66274. size?: number;
  66275. sizeX?: number;
  66276. sizeY?: number;
  66277. sizeZ?: number;
  66278. custom?: any;
  66279. faceUV?: Vector4[];
  66280. faceColors?: Color4[];
  66281. flat?: boolean;
  66282. updatable?: boolean;
  66283. sideOrientation?: number;
  66284. frontUVs?: Vector4;
  66285. backUVs?: Vector4;
  66286. }, scene?: Nullable<Scene>): Mesh;
  66287. /**
  66288. * Creates a decal mesh.
  66289. * 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
  66290. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66291. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66292. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66293. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66294. * @param name defines the name of the mesh
  66295. * @param sourceMesh defines the mesh where the decal must be applied
  66296. * @param options defines the options used to create the mesh
  66297. * @param scene defines the hosting scene
  66298. * @returns the decal mesh
  66299. * @see https://doc.babylonjs.com/how_to/decals
  66300. */
  66301. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66302. position?: Vector3;
  66303. normal?: Vector3;
  66304. size?: Vector3;
  66305. angle?: number;
  66306. }): Mesh;
  66307. }
  66308. }
  66309. declare module BABYLON {
  66310. /**
  66311. * A simplifier interface for future simplification implementations
  66312. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66313. */
  66314. export interface ISimplifier {
  66315. /**
  66316. * Simplification of a given mesh according to the given settings.
  66317. * Since this requires computation, it is assumed that the function runs async.
  66318. * @param settings The settings of the simplification, including quality and distance
  66319. * @param successCallback A callback that will be called after the mesh was simplified.
  66320. * @param errorCallback in case of an error, this callback will be called. optional.
  66321. */
  66322. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66323. }
  66324. /**
  66325. * Expected simplification settings.
  66326. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66327. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66328. */
  66329. export interface ISimplificationSettings {
  66330. /**
  66331. * Gets or sets the expected quality
  66332. */
  66333. quality: number;
  66334. /**
  66335. * Gets or sets the distance when this optimized version should be used
  66336. */
  66337. distance: number;
  66338. /**
  66339. * Gets an already optimized mesh
  66340. */
  66341. optimizeMesh?: boolean;
  66342. }
  66343. /**
  66344. * Class used to specify simplification options
  66345. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66346. */
  66347. export class SimplificationSettings implements ISimplificationSettings {
  66348. /** expected quality */
  66349. quality: number;
  66350. /** distance when this optimized version should be used */
  66351. distance: number;
  66352. /** already optimized mesh */
  66353. optimizeMesh?: boolean | undefined;
  66354. /**
  66355. * Creates a SimplificationSettings
  66356. * @param quality expected quality
  66357. * @param distance distance when this optimized version should be used
  66358. * @param optimizeMesh already optimized mesh
  66359. */
  66360. constructor(
  66361. /** expected quality */
  66362. quality: number,
  66363. /** distance when this optimized version should be used */
  66364. distance: number,
  66365. /** already optimized mesh */
  66366. optimizeMesh?: boolean | undefined);
  66367. }
  66368. /**
  66369. * Interface used to define a simplification task
  66370. */
  66371. export interface ISimplificationTask {
  66372. /**
  66373. * Array of settings
  66374. */
  66375. settings: Array<ISimplificationSettings>;
  66376. /**
  66377. * Simplification type
  66378. */
  66379. simplificationType: SimplificationType;
  66380. /**
  66381. * Mesh to simplify
  66382. */
  66383. mesh: Mesh;
  66384. /**
  66385. * Callback called on success
  66386. */
  66387. successCallback?: () => void;
  66388. /**
  66389. * Defines if parallel processing can be used
  66390. */
  66391. parallelProcessing: boolean;
  66392. }
  66393. /**
  66394. * Queue used to order the simplification tasks
  66395. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66396. */
  66397. export class SimplificationQueue {
  66398. private _simplificationArray;
  66399. /**
  66400. * Gets a boolean indicating that the process is still running
  66401. */
  66402. running: boolean;
  66403. /**
  66404. * Creates a new queue
  66405. */
  66406. constructor();
  66407. /**
  66408. * Adds a new simplification task
  66409. * @param task defines a task to add
  66410. */
  66411. addTask(task: ISimplificationTask): void;
  66412. /**
  66413. * Execute next task
  66414. */
  66415. executeNext(): void;
  66416. /**
  66417. * Execute a simplification task
  66418. * @param task defines the task to run
  66419. */
  66420. runSimplification(task: ISimplificationTask): void;
  66421. private getSimplifier;
  66422. }
  66423. /**
  66424. * The implemented types of simplification
  66425. * At the moment only Quadratic Error Decimation is implemented
  66426. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66427. */
  66428. export enum SimplificationType {
  66429. /** Quadratic error decimation */
  66430. QUADRATIC = 0
  66431. }
  66432. /**
  66433. * An implementation of the Quadratic Error simplification algorithm.
  66434. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66435. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66436. * @author RaananW
  66437. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66438. */
  66439. export class QuadraticErrorSimplification implements ISimplifier {
  66440. private _mesh;
  66441. private triangles;
  66442. private vertices;
  66443. private references;
  66444. private _reconstructedMesh;
  66445. /** Gets or sets the number pf sync interations */
  66446. syncIterations: number;
  66447. /** Gets or sets the aggressiveness of the simplifier */
  66448. aggressiveness: number;
  66449. /** Gets or sets the number of allowed iterations for decimation */
  66450. decimationIterations: number;
  66451. /** Gets or sets the espilon to use for bounding box computation */
  66452. boundingBoxEpsilon: number;
  66453. /**
  66454. * Creates a new QuadraticErrorSimplification
  66455. * @param _mesh defines the target mesh
  66456. */
  66457. constructor(_mesh: Mesh);
  66458. /**
  66459. * Simplification of a given mesh according to the given settings.
  66460. * Since this requires computation, it is assumed that the function runs async.
  66461. * @param settings The settings of the simplification, including quality and distance
  66462. * @param successCallback A callback that will be called after the mesh was simplified.
  66463. */
  66464. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66465. private runDecimation;
  66466. private initWithMesh;
  66467. private init;
  66468. private reconstructMesh;
  66469. private initDecimatedMesh;
  66470. private isFlipped;
  66471. private updateTriangles;
  66472. private identifyBorder;
  66473. private updateMesh;
  66474. private vertexError;
  66475. private calculateError;
  66476. }
  66477. }
  66478. declare module BABYLON {
  66479. interface Scene {
  66480. /** @hidden (Backing field) */
  66481. _simplificationQueue: SimplificationQueue;
  66482. /**
  66483. * Gets or sets the simplification queue attached to the scene
  66484. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66485. */
  66486. simplificationQueue: SimplificationQueue;
  66487. }
  66488. interface Mesh {
  66489. /**
  66490. * Simplify the mesh according to the given array of settings.
  66491. * Function will return immediately and will simplify async
  66492. * @param settings a collection of simplification settings
  66493. * @param parallelProcessing should all levels calculate parallel or one after the other
  66494. * @param simplificationType the type of simplification to run
  66495. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66496. * @returns the current mesh
  66497. */
  66498. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66499. }
  66500. /**
  66501. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66502. * created in a scene
  66503. */
  66504. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66505. /**
  66506. * The component name helpfull to identify the component in the list of scene components.
  66507. */
  66508. readonly name: string;
  66509. /**
  66510. * The scene the component belongs to.
  66511. */
  66512. scene: Scene;
  66513. /**
  66514. * Creates a new instance of the component for the given scene
  66515. * @param scene Defines the scene to register the component in
  66516. */
  66517. constructor(scene: Scene);
  66518. /**
  66519. * Registers the component in a given scene
  66520. */
  66521. register(): void;
  66522. /**
  66523. * Rebuilds the elements related to this component in case of
  66524. * context lost for instance.
  66525. */
  66526. rebuild(): void;
  66527. /**
  66528. * Disposes the component and the associated ressources
  66529. */
  66530. dispose(): void;
  66531. private _beforeCameraUpdate;
  66532. }
  66533. }
  66534. declare module BABYLON {
  66535. interface Mesh {
  66536. /**
  66537. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66538. */
  66539. thinInstanceEnablePicking: boolean;
  66540. /**
  66541. * Creates a new thin instance
  66542. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66543. * @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
  66544. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66545. */
  66546. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66547. /**
  66548. * Adds the transformation (matrix) of the current mesh as a thin instance
  66549. * @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
  66550. * @returns the thin instance index number
  66551. */
  66552. thinInstanceAddSelf(refresh: boolean): number;
  66553. /**
  66554. * Registers a custom attribute to be used with thin instances
  66555. * @param kind name of the attribute
  66556. * @param stride size in floats of the attribute
  66557. */
  66558. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66559. /**
  66560. * Sets the matrix of a thin instance
  66561. * @param index index of the thin instance
  66562. * @param matrix matrix to set
  66563. * @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
  66564. */
  66565. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66566. /**
  66567. * Sets the value of a custom attribute for a thin instance
  66568. * @param kind name of the attribute
  66569. * @param index index of the thin instance
  66570. * @param value value to set
  66571. * @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
  66572. */
  66573. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66574. /**
  66575. * 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.
  66576. */
  66577. thinInstanceCount: number;
  66578. /**
  66579. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66580. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66581. * @param buffer buffer to set
  66582. * @param stride size in floats of each value of the buffer
  66583. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66584. */
  66585. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66586. /**
  66587. * Gets the list of world matrices
  66588. * @return an array containing all the world matrices from the thin instances
  66589. */
  66590. thinInstanceGetWorldMatrices(): Matrix[];
  66591. /**
  66592. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66593. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66594. */
  66595. thinInstanceBufferUpdated(kind: string): void;
  66596. /**
  66597. * Refreshes the bounding info, taking into account all the thin instances defined
  66598. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66599. */
  66600. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66601. /** @hidden */
  66602. _thinInstanceInitializeUserStorage(): void;
  66603. /** @hidden */
  66604. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66605. /** @hidden */
  66606. _userThinInstanceBuffersStorage: {
  66607. data: {
  66608. [key: string]: Float32Array;
  66609. };
  66610. sizes: {
  66611. [key: string]: number;
  66612. };
  66613. vertexBuffers: {
  66614. [key: string]: Nullable<VertexBuffer>;
  66615. };
  66616. strides: {
  66617. [key: string]: number;
  66618. };
  66619. };
  66620. }
  66621. }
  66622. declare module BABYLON {
  66623. /**
  66624. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66625. */
  66626. export interface INavigationEnginePlugin {
  66627. /**
  66628. * plugin name
  66629. */
  66630. name: string;
  66631. /**
  66632. * Creates a navigation mesh
  66633. * @param meshes array of all the geometry used to compute the navigatio mesh
  66634. * @param parameters bunch of parameters used to filter geometry
  66635. */
  66636. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66637. /**
  66638. * Create a navigation mesh debug mesh
  66639. * @param scene is where the mesh will be added
  66640. * @returns debug display mesh
  66641. */
  66642. createDebugNavMesh(scene: Scene): Mesh;
  66643. /**
  66644. * Get a navigation mesh constrained position, closest to the parameter position
  66645. * @param position world position
  66646. * @returns the closest point to position constrained by the navigation mesh
  66647. */
  66648. getClosestPoint(position: Vector3): Vector3;
  66649. /**
  66650. * Get a navigation mesh constrained position, closest to the parameter position
  66651. * @param position world position
  66652. * @param result output the closest point to position constrained by the navigation mesh
  66653. */
  66654. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66655. /**
  66656. * Get a navigation mesh constrained position, within a particular radius
  66657. * @param position world position
  66658. * @param maxRadius the maximum distance to the constrained world position
  66659. * @returns the closest point to position constrained by the navigation mesh
  66660. */
  66661. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66662. /**
  66663. * Get a navigation mesh constrained position, within a particular radius
  66664. * @param position world position
  66665. * @param maxRadius the maximum distance to the constrained world position
  66666. * @param result output the closest point to position constrained by the navigation mesh
  66667. */
  66668. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66669. /**
  66670. * Compute the final position from a segment made of destination-position
  66671. * @param position world position
  66672. * @param destination world position
  66673. * @returns the resulting point along the navmesh
  66674. */
  66675. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66676. /**
  66677. * Compute the final position from a segment made of destination-position
  66678. * @param position world position
  66679. * @param destination world position
  66680. * @param result output the resulting point along the navmesh
  66681. */
  66682. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66683. /**
  66684. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66685. * @param start world position
  66686. * @param end world position
  66687. * @returns array containing world position composing the path
  66688. */
  66689. computePath(start: Vector3, end: Vector3): Vector3[];
  66690. /**
  66691. * If this plugin is supported
  66692. * @returns true if plugin is supported
  66693. */
  66694. isSupported(): boolean;
  66695. /**
  66696. * Create a new Crowd so you can add agents
  66697. * @param maxAgents the maximum agent count in the crowd
  66698. * @param maxAgentRadius the maximum radius an agent can have
  66699. * @param scene to attach the crowd to
  66700. * @returns the crowd you can add agents to
  66701. */
  66702. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66703. /**
  66704. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66705. * The queries will try to find a solution within those bounds
  66706. * default is (1,1,1)
  66707. * @param extent x,y,z value that define the extent around the queries point of reference
  66708. */
  66709. setDefaultQueryExtent(extent: Vector3): void;
  66710. /**
  66711. * Get the Bounding box extent specified by setDefaultQueryExtent
  66712. * @returns the box extent values
  66713. */
  66714. getDefaultQueryExtent(): Vector3;
  66715. /**
  66716. * build the navmesh from a previously saved state using getNavmeshData
  66717. * @param data the Uint8Array returned by getNavmeshData
  66718. */
  66719. buildFromNavmeshData(data: Uint8Array): void;
  66720. /**
  66721. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66722. * @returns data the Uint8Array that can be saved and reused
  66723. */
  66724. getNavmeshData(): Uint8Array;
  66725. /**
  66726. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66727. * @param result output the box extent values
  66728. */
  66729. getDefaultQueryExtentToRef(result: Vector3): void;
  66730. /**
  66731. * Release all resources
  66732. */
  66733. dispose(): void;
  66734. }
  66735. /**
  66736. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66737. */
  66738. export interface ICrowd {
  66739. /**
  66740. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66741. * You can attach anything to that node. The node position is updated in the scene update tick.
  66742. * @param pos world position that will be constrained by the navigation mesh
  66743. * @param parameters agent parameters
  66744. * @param transform hooked to the agent that will be update by the scene
  66745. * @returns agent index
  66746. */
  66747. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66748. /**
  66749. * Returns the agent position in world space
  66750. * @param index agent index returned by addAgent
  66751. * @returns world space position
  66752. */
  66753. getAgentPosition(index: number): Vector3;
  66754. /**
  66755. * Gets the agent position result in world space
  66756. * @param index agent index returned by addAgent
  66757. * @param result output world space position
  66758. */
  66759. getAgentPositionToRef(index: number, result: Vector3): void;
  66760. /**
  66761. * Gets the agent velocity in world space
  66762. * @param index agent index returned by addAgent
  66763. * @returns world space velocity
  66764. */
  66765. getAgentVelocity(index: number): Vector3;
  66766. /**
  66767. * Gets the agent velocity result in world space
  66768. * @param index agent index returned by addAgent
  66769. * @param result output world space velocity
  66770. */
  66771. getAgentVelocityToRef(index: number, result: Vector3): void;
  66772. /**
  66773. * remove a particular agent previously created
  66774. * @param index agent index returned by addAgent
  66775. */
  66776. removeAgent(index: number): void;
  66777. /**
  66778. * get the list of all agents attached to this crowd
  66779. * @returns list of agent indices
  66780. */
  66781. getAgents(): number[];
  66782. /**
  66783. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66784. * @param deltaTime in seconds
  66785. */
  66786. update(deltaTime: number): void;
  66787. /**
  66788. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66789. * @param index agent index returned by addAgent
  66790. * @param destination targeted world position
  66791. */
  66792. agentGoto(index: number, destination: Vector3): void;
  66793. /**
  66794. * Teleport the agent to a new position
  66795. * @param index agent index returned by addAgent
  66796. * @param destination targeted world position
  66797. */
  66798. agentTeleport(index: number, destination: Vector3): void;
  66799. /**
  66800. * Update agent parameters
  66801. * @param index agent index returned by addAgent
  66802. * @param parameters agent parameters
  66803. */
  66804. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66805. /**
  66806. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66807. * The queries will try to find a solution within those bounds
  66808. * default is (1,1,1)
  66809. * @param extent x,y,z value that define the extent around the queries point of reference
  66810. */
  66811. setDefaultQueryExtent(extent: Vector3): void;
  66812. /**
  66813. * Get the Bounding box extent specified by setDefaultQueryExtent
  66814. * @returns the box extent values
  66815. */
  66816. getDefaultQueryExtent(): Vector3;
  66817. /**
  66818. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66819. * @param result output the box extent values
  66820. */
  66821. getDefaultQueryExtentToRef(result: Vector3): void;
  66822. /**
  66823. * Release all resources
  66824. */
  66825. dispose(): void;
  66826. }
  66827. /**
  66828. * Configures an agent
  66829. */
  66830. export interface IAgentParameters {
  66831. /**
  66832. * Agent radius. [Limit: >= 0]
  66833. */
  66834. radius: number;
  66835. /**
  66836. * Agent height. [Limit: > 0]
  66837. */
  66838. height: number;
  66839. /**
  66840. * Maximum allowed acceleration. [Limit: >= 0]
  66841. */
  66842. maxAcceleration: number;
  66843. /**
  66844. * Maximum allowed speed. [Limit: >= 0]
  66845. */
  66846. maxSpeed: number;
  66847. /**
  66848. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66849. */
  66850. collisionQueryRange: number;
  66851. /**
  66852. * The path visibility optimization range. [Limit: > 0]
  66853. */
  66854. pathOptimizationRange: number;
  66855. /**
  66856. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66857. */
  66858. separationWeight: number;
  66859. }
  66860. /**
  66861. * Configures the navigation mesh creation
  66862. */
  66863. export interface INavMeshParameters {
  66864. /**
  66865. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66866. */
  66867. cs: number;
  66868. /**
  66869. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66870. */
  66871. ch: number;
  66872. /**
  66873. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66874. */
  66875. walkableSlopeAngle: number;
  66876. /**
  66877. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66878. * be considered walkable. [Limit: >= 3] [Units: vx]
  66879. */
  66880. walkableHeight: number;
  66881. /**
  66882. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66883. */
  66884. walkableClimb: number;
  66885. /**
  66886. * The distance to erode/shrink the walkable area of the heightfield away from
  66887. * obstructions. [Limit: >=0] [Units: vx]
  66888. */
  66889. walkableRadius: number;
  66890. /**
  66891. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66892. */
  66893. maxEdgeLen: number;
  66894. /**
  66895. * The maximum distance a simplfied contour's border edges should deviate
  66896. * the original raw contour. [Limit: >=0] [Units: vx]
  66897. */
  66898. maxSimplificationError: number;
  66899. /**
  66900. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66901. */
  66902. minRegionArea: number;
  66903. /**
  66904. * Any regions with a span count smaller than this value will, if possible,
  66905. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66906. */
  66907. mergeRegionArea: number;
  66908. /**
  66909. * The maximum number of vertices allowed for polygons generated during the
  66910. * contour to polygon conversion process. [Limit: >= 3]
  66911. */
  66912. maxVertsPerPoly: number;
  66913. /**
  66914. * Sets the sampling distance to use when generating the detail mesh.
  66915. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66916. */
  66917. detailSampleDist: number;
  66918. /**
  66919. * The maximum distance the detail mesh surface should deviate from heightfield
  66920. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66921. */
  66922. detailSampleMaxError: number;
  66923. }
  66924. }
  66925. declare module BABYLON {
  66926. /**
  66927. * RecastJS navigation plugin
  66928. */
  66929. export class RecastJSPlugin implements INavigationEnginePlugin {
  66930. /**
  66931. * Reference to the Recast library
  66932. */
  66933. bjsRECAST: any;
  66934. /**
  66935. * plugin name
  66936. */
  66937. name: string;
  66938. /**
  66939. * the first navmesh created. We might extend this to support multiple navmeshes
  66940. */
  66941. navMesh: any;
  66942. /**
  66943. * Initializes the recastJS plugin
  66944. * @param recastInjection can be used to inject your own recast reference
  66945. */
  66946. constructor(recastInjection?: any);
  66947. /**
  66948. * Creates a navigation mesh
  66949. * @param meshes array of all the geometry used to compute the navigatio mesh
  66950. * @param parameters bunch of parameters used to filter geometry
  66951. */
  66952. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66953. /**
  66954. * Create a navigation mesh debug mesh
  66955. * @param scene is where the mesh will be added
  66956. * @returns debug display mesh
  66957. */
  66958. createDebugNavMesh(scene: Scene): Mesh;
  66959. /**
  66960. * Get a navigation mesh constrained position, closest to the parameter position
  66961. * @param position world position
  66962. * @returns the closest point to position constrained by the navigation mesh
  66963. */
  66964. getClosestPoint(position: Vector3): Vector3;
  66965. /**
  66966. * Get a navigation mesh constrained position, closest to the parameter position
  66967. * @param position world position
  66968. * @param result output the closest point to position constrained by the navigation mesh
  66969. */
  66970. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66971. /**
  66972. * Get a navigation mesh constrained position, within a particular radius
  66973. * @param position world position
  66974. * @param maxRadius the maximum distance to the constrained world position
  66975. * @returns the closest point to position constrained by the navigation mesh
  66976. */
  66977. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66978. /**
  66979. * Get a navigation mesh constrained position, within a particular radius
  66980. * @param position world position
  66981. * @param maxRadius the maximum distance to the constrained world position
  66982. * @param result output the closest point to position constrained by the navigation mesh
  66983. */
  66984. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66985. /**
  66986. * Compute the final position from a segment made of destination-position
  66987. * @param position world position
  66988. * @param destination world position
  66989. * @returns the resulting point along the navmesh
  66990. */
  66991. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66992. /**
  66993. * Compute the final position from a segment made of destination-position
  66994. * @param position world position
  66995. * @param destination world position
  66996. * @param result output the resulting point along the navmesh
  66997. */
  66998. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66999. /**
  67000. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67001. * @param start world position
  67002. * @param end world position
  67003. * @returns array containing world position composing the path
  67004. */
  67005. computePath(start: Vector3, end: Vector3): Vector3[];
  67006. /**
  67007. * Create a new Crowd so you can add agents
  67008. * @param maxAgents the maximum agent count in the crowd
  67009. * @param maxAgentRadius the maximum radius an agent can have
  67010. * @param scene to attach the crowd to
  67011. * @returns the crowd you can add agents to
  67012. */
  67013. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67014. /**
  67015. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67016. * The queries will try to find a solution within those bounds
  67017. * default is (1,1,1)
  67018. * @param extent x,y,z value that define the extent around the queries point of reference
  67019. */
  67020. setDefaultQueryExtent(extent: Vector3): void;
  67021. /**
  67022. * Get the Bounding box extent specified by setDefaultQueryExtent
  67023. * @returns the box extent values
  67024. */
  67025. getDefaultQueryExtent(): Vector3;
  67026. /**
  67027. * build the navmesh from a previously saved state using getNavmeshData
  67028. * @param data the Uint8Array returned by getNavmeshData
  67029. */
  67030. buildFromNavmeshData(data: Uint8Array): void;
  67031. /**
  67032. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67033. * @returns data the Uint8Array that can be saved and reused
  67034. */
  67035. getNavmeshData(): Uint8Array;
  67036. /**
  67037. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67038. * @param result output the box extent values
  67039. */
  67040. getDefaultQueryExtentToRef(result: Vector3): void;
  67041. /**
  67042. * Disposes
  67043. */
  67044. dispose(): void;
  67045. /**
  67046. * If this plugin is supported
  67047. * @returns true if plugin is supported
  67048. */
  67049. isSupported(): boolean;
  67050. }
  67051. /**
  67052. * Recast detour crowd implementation
  67053. */
  67054. export class RecastJSCrowd implements ICrowd {
  67055. /**
  67056. * Recast/detour plugin
  67057. */
  67058. bjsRECASTPlugin: RecastJSPlugin;
  67059. /**
  67060. * Link to the detour crowd
  67061. */
  67062. recastCrowd: any;
  67063. /**
  67064. * One transform per agent
  67065. */
  67066. transforms: TransformNode[];
  67067. /**
  67068. * All agents created
  67069. */
  67070. agents: number[];
  67071. /**
  67072. * Link to the scene is kept to unregister the crowd from the scene
  67073. */
  67074. private _scene;
  67075. /**
  67076. * Observer for crowd updates
  67077. */
  67078. private _onBeforeAnimationsObserver;
  67079. /**
  67080. * Constructor
  67081. * @param plugin recastJS plugin
  67082. * @param maxAgents the maximum agent count in the crowd
  67083. * @param maxAgentRadius the maximum radius an agent can have
  67084. * @param scene to attach the crowd to
  67085. * @returns the crowd you can add agents to
  67086. */
  67087. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67088. /**
  67089. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67090. * You can attach anything to that node. The node position is updated in the scene update tick.
  67091. * @param pos world position that will be constrained by the navigation mesh
  67092. * @param parameters agent parameters
  67093. * @param transform hooked to the agent that will be update by the scene
  67094. * @returns agent index
  67095. */
  67096. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67097. /**
  67098. * Returns the agent position in world space
  67099. * @param index agent index returned by addAgent
  67100. * @returns world space position
  67101. */
  67102. getAgentPosition(index: number): Vector3;
  67103. /**
  67104. * Returns the agent position result in world space
  67105. * @param index agent index returned by addAgent
  67106. * @param result output world space position
  67107. */
  67108. getAgentPositionToRef(index: number, result: Vector3): void;
  67109. /**
  67110. * Returns the agent velocity in world space
  67111. * @param index agent index returned by addAgent
  67112. * @returns world space velocity
  67113. */
  67114. getAgentVelocity(index: number): Vector3;
  67115. /**
  67116. * Returns the agent velocity result in world space
  67117. * @param index agent index returned by addAgent
  67118. * @param result output world space velocity
  67119. */
  67120. getAgentVelocityToRef(index: number, result: Vector3): void;
  67121. /**
  67122. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67123. * @param index agent index returned by addAgent
  67124. * @param destination targeted world position
  67125. */
  67126. agentGoto(index: number, destination: Vector3): void;
  67127. /**
  67128. * Teleport the agent to a new position
  67129. * @param index agent index returned by addAgent
  67130. * @param destination targeted world position
  67131. */
  67132. agentTeleport(index: number, destination: Vector3): void;
  67133. /**
  67134. * Update agent parameters
  67135. * @param index agent index returned by addAgent
  67136. * @param parameters agent parameters
  67137. */
  67138. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67139. /**
  67140. * remove a particular agent previously created
  67141. * @param index agent index returned by addAgent
  67142. */
  67143. removeAgent(index: number): void;
  67144. /**
  67145. * get the list of all agents attached to this crowd
  67146. * @returns list of agent indices
  67147. */
  67148. getAgents(): number[];
  67149. /**
  67150. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67151. * @param deltaTime in seconds
  67152. */
  67153. update(deltaTime: number): void;
  67154. /**
  67155. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67156. * The queries will try to find a solution within those bounds
  67157. * default is (1,1,1)
  67158. * @param extent x,y,z value that define the extent around the queries point of reference
  67159. */
  67160. setDefaultQueryExtent(extent: Vector3): void;
  67161. /**
  67162. * Get the Bounding box extent specified by setDefaultQueryExtent
  67163. * @returns the box extent values
  67164. */
  67165. getDefaultQueryExtent(): Vector3;
  67166. /**
  67167. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67168. * @param result output the box extent values
  67169. */
  67170. getDefaultQueryExtentToRef(result: Vector3): void;
  67171. /**
  67172. * Release all resources
  67173. */
  67174. dispose(): void;
  67175. }
  67176. }
  67177. declare module BABYLON {
  67178. /**
  67179. * Class used to enable access to IndexedDB
  67180. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67181. */
  67182. export class Database implements IOfflineProvider {
  67183. private _callbackManifestChecked;
  67184. private _currentSceneUrl;
  67185. private _db;
  67186. private _enableSceneOffline;
  67187. private _enableTexturesOffline;
  67188. private _manifestVersionFound;
  67189. private _mustUpdateRessources;
  67190. private _hasReachedQuota;
  67191. private _isSupported;
  67192. private _idbFactory;
  67193. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67194. private static IsUASupportingBlobStorage;
  67195. /**
  67196. * Gets a boolean indicating if Database storate is enabled (off by default)
  67197. */
  67198. static IDBStorageEnabled: boolean;
  67199. /**
  67200. * Gets a boolean indicating if scene must be saved in the database
  67201. */
  67202. get enableSceneOffline(): boolean;
  67203. /**
  67204. * Gets a boolean indicating if textures must be saved in the database
  67205. */
  67206. get enableTexturesOffline(): boolean;
  67207. /**
  67208. * Creates a new Database
  67209. * @param urlToScene defines the url to load the scene
  67210. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67211. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67212. */
  67213. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67214. private static _ParseURL;
  67215. private static _ReturnFullUrlLocation;
  67216. private _checkManifestFile;
  67217. /**
  67218. * Open the database and make it available
  67219. * @param successCallback defines the callback to call on success
  67220. * @param errorCallback defines the callback to call on error
  67221. */
  67222. open(successCallback: () => void, errorCallback: () => void): void;
  67223. /**
  67224. * Loads an image from the database
  67225. * @param url defines the url to load from
  67226. * @param image defines the target DOM image
  67227. */
  67228. loadImage(url: string, image: HTMLImageElement): void;
  67229. private _loadImageFromDBAsync;
  67230. private _saveImageIntoDBAsync;
  67231. private _checkVersionFromDB;
  67232. private _loadVersionFromDBAsync;
  67233. private _saveVersionIntoDBAsync;
  67234. /**
  67235. * Loads a file from database
  67236. * @param url defines the URL to load from
  67237. * @param sceneLoaded defines a callback to call on success
  67238. * @param progressCallBack defines a callback to call when progress changed
  67239. * @param errorCallback defines a callback to call on error
  67240. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67241. */
  67242. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67243. private _loadFileAsync;
  67244. private _saveFileAsync;
  67245. /**
  67246. * Validates if xhr data is correct
  67247. * @param xhr defines the request to validate
  67248. * @param dataType defines the expected data type
  67249. * @returns true if data is correct
  67250. */
  67251. private static _ValidateXHRData;
  67252. }
  67253. }
  67254. declare module BABYLON {
  67255. /** @hidden */
  67256. export var gpuUpdateParticlesPixelShader: {
  67257. name: string;
  67258. shader: string;
  67259. };
  67260. }
  67261. declare module BABYLON {
  67262. /** @hidden */
  67263. export var gpuUpdateParticlesVertexShader: {
  67264. name: string;
  67265. shader: string;
  67266. };
  67267. }
  67268. declare module BABYLON {
  67269. /** @hidden */
  67270. export var clipPlaneFragmentDeclaration2: {
  67271. name: string;
  67272. shader: string;
  67273. };
  67274. }
  67275. declare module BABYLON {
  67276. /** @hidden */
  67277. export var gpuRenderParticlesPixelShader: {
  67278. name: string;
  67279. shader: string;
  67280. };
  67281. }
  67282. declare module BABYLON {
  67283. /** @hidden */
  67284. export var clipPlaneVertexDeclaration2: {
  67285. name: string;
  67286. shader: string;
  67287. };
  67288. }
  67289. declare module BABYLON {
  67290. /** @hidden */
  67291. export var gpuRenderParticlesVertexShader: {
  67292. name: string;
  67293. shader: string;
  67294. };
  67295. }
  67296. declare module BABYLON {
  67297. /**
  67298. * This represents a GPU particle system in Babylon
  67299. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67300. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67301. */
  67302. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67303. /**
  67304. * The layer mask we are rendering the particles through.
  67305. */
  67306. layerMask: number;
  67307. private _capacity;
  67308. private _activeCount;
  67309. private _currentActiveCount;
  67310. private _accumulatedCount;
  67311. private _renderEffect;
  67312. private _updateEffect;
  67313. private _buffer0;
  67314. private _buffer1;
  67315. private _spriteBuffer;
  67316. private _updateVAO;
  67317. private _renderVAO;
  67318. private _targetIndex;
  67319. private _sourceBuffer;
  67320. private _targetBuffer;
  67321. private _currentRenderId;
  67322. private _started;
  67323. private _stopped;
  67324. private _timeDelta;
  67325. private _randomTexture;
  67326. private _randomTexture2;
  67327. private _attributesStrideSize;
  67328. private _updateEffectOptions;
  67329. private _randomTextureSize;
  67330. private _actualFrame;
  67331. private _customEffect;
  67332. private readonly _rawTextureWidth;
  67333. /**
  67334. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67335. */
  67336. static get IsSupported(): boolean;
  67337. /**
  67338. * An event triggered when the system is disposed.
  67339. */
  67340. onDisposeObservable: Observable<IParticleSystem>;
  67341. /**
  67342. * Gets the maximum number of particles active at the same time.
  67343. * @returns The max number of active particles.
  67344. */
  67345. getCapacity(): number;
  67346. /**
  67347. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67348. * to override the particles.
  67349. */
  67350. forceDepthWrite: boolean;
  67351. /**
  67352. * Gets or set the number of active particles
  67353. */
  67354. get activeParticleCount(): number;
  67355. set activeParticleCount(value: number);
  67356. private _preWarmDone;
  67357. /**
  67358. * Specifies if the particles are updated in emitter local space or world space.
  67359. */
  67360. isLocal: boolean;
  67361. /** Gets or sets a matrix to use to compute projection */
  67362. defaultProjectionMatrix: Matrix;
  67363. /**
  67364. * Is this system ready to be used/rendered
  67365. * @return true if the system is ready
  67366. */
  67367. isReady(): boolean;
  67368. /**
  67369. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67370. * @returns True if it has been started, otherwise false.
  67371. */
  67372. isStarted(): boolean;
  67373. /**
  67374. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67375. * @returns True if it has been stopped, otherwise false.
  67376. */
  67377. isStopped(): boolean;
  67378. /**
  67379. * Gets a boolean indicating that the system is stopping
  67380. * @returns true if the system is currently stopping
  67381. */
  67382. isStopping(): boolean;
  67383. /**
  67384. * Gets the number of particles active at the same time.
  67385. * @returns The number of active particles.
  67386. */
  67387. getActiveCount(): number;
  67388. /**
  67389. * Starts the particle system and begins to emit
  67390. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67391. */
  67392. start(delay?: number): void;
  67393. /**
  67394. * Stops the particle system.
  67395. */
  67396. stop(): void;
  67397. /**
  67398. * Remove all active particles
  67399. */
  67400. reset(): void;
  67401. /**
  67402. * Returns the string "GPUParticleSystem"
  67403. * @returns a string containing the class name
  67404. */
  67405. getClassName(): string;
  67406. /**
  67407. * Gets the custom effect used to render the particles
  67408. * @param blendMode Blend mode for which the effect should be retrieved
  67409. * @returns The effect
  67410. */
  67411. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67412. /**
  67413. * Sets the custom effect used to render the particles
  67414. * @param effect The effect to set
  67415. * @param blendMode Blend mode for which the effect should be set
  67416. */
  67417. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67418. /** @hidden */
  67419. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67420. /**
  67421. * Observable that will be called just before the particles are drawn
  67422. */
  67423. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67424. /**
  67425. * Gets the name of the particle vertex shader
  67426. */
  67427. get vertexShaderName(): string;
  67428. private _colorGradientsTexture;
  67429. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67430. /**
  67431. * Adds a new color gradient
  67432. * @param gradient defines the gradient to use (between 0 and 1)
  67433. * @param color1 defines the color to affect to the specified gradient
  67434. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67435. * @returns the current particle system
  67436. */
  67437. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67438. private _refreshColorGradient;
  67439. /** Force the system to rebuild all gradients that need to be resync */
  67440. forceRefreshGradients(): void;
  67441. /**
  67442. * Remove a specific color gradient
  67443. * @param gradient defines the gradient to remove
  67444. * @returns the current particle system
  67445. */
  67446. removeColorGradient(gradient: number): GPUParticleSystem;
  67447. private _angularSpeedGradientsTexture;
  67448. private _sizeGradientsTexture;
  67449. private _velocityGradientsTexture;
  67450. private _limitVelocityGradientsTexture;
  67451. private _dragGradientsTexture;
  67452. private _addFactorGradient;
  67453. /**
  67454. * Adds a new size gradient
  67455. * @param gradient defines the gradient to use (between 0 and 1)
  67456. * @param factor defines the size factor to affect to the specified gradient
  67457. * @returns the current particle system
  67458. */
  67459. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67460. /**
  67461. * Remove a specific size gradient
  67462. * @param gradient defines the gradient to remove
  67463. * @returns the current particle system
  67464. */
  67465. removeSizeGradient(gradient: number): GPUParticleSystem;
  67466. private _refreshFactorGradient;
  67467. /**
  67468. * Adds a new angular speed gradient
  67469. * @param gradient defines the gradient to use (between 0 and 1)
  67470. * @param factor defines the angular speed to affect to the specified gradient
  67471. * @returns the current particle system
  67472. */
  67473. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67474. /**
  67475. * Remove a specific angular speed gradient
  67476. * @param gradient defines the gradient to remove
  67477. * @returns the current particle system
  67478. */
  67479. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67480. /**
  67481. * Adds a new velocity gradient
  67482. * @param gradient defines the gradient to use (between 0 and 1)
  67483. * @param factor defines the velocity to affect to the specified gradient
  67484. * @returns the current particle system
  67485. */
  67486. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67487. /**
  67488. * Remove a specific velocity gradient
  67489. * @param gradient defines the gradient to remove
  67490. * @returns the current particle system
  67491. */
  67492. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67493. /**
  67494. * Adds a new limit velocity gradient
  67495. * @param gradient defines the gradient to use (between 0 and 1)
  67496. * @param factor defines the limit velocity value to affect to the specified gradient
  67497. * @returns the current particle system
  67498. */
  67499. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67500. /**
  67501. * Remove a specific limit velocity gradient
  67502. * @param gradient defines the gradient to remove
  67503. * @returns the current particle system
  67504. */
  67505. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67506. /**
  67507. * Adds a new drag gradient
  67508. * @param gradient defines the gradient to use (between 0 and 1)
  67509. * @param factor defines the drag value to affect to the specified gradient
  67510. * @returns the current particle system
  67511. */
  67512. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67513. /**
  67514. * Remove a specific drag gradient
  67515. * @param gradient defines the gradient to remove
  67516. * @returns the current particle system
  67517. */
  67518. removeDragGradient(gradient: number): GPUParticleSystem;
  67519. /**
  67520. * Not supported by GPUParticleSystem
  67521. * @param gradient defines the gradient to use (between 0 and 1)
  67522. * @param factor defines the emit rate value to affect to the specified gradient
  67523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67524. * @returns the current particle system
  67525. */
  67526. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67527. /**
  67528. * Not supported by GPUParticleSystem
  67529. * @param gradient defines the gradient to remove
  67530. * @returns the current particle system
  67531. */
  67532. removeEmitRateGradient(gradient: number): IParticleSystem;
  67533. /**
  67534. * Not supported by GPUParticleSystem
  67535. * @param gradient defines the gradient to use (between 0 and 1)
  67536. * @param factor defines the start size value to affect to the specified gradient
  67537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67538. * @returns the current particle system
  67539. */
  67540. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67541. /**
  67542. * Not supported by GPUParticleSystem
  67543. * @param gradient defines the gradient to remove
  67544. * @returns the current particle system
  67545. */
  67546. removeStartSizeGradient(gradient: number): IParticleSystem;
  67547. /**
  67548. * Not supported by GPUParticleSystem
  67549. * @param gradient defines the gradient to use (between 0 and 1)
  67550. * @param min defines the color remap minimal range
  67551. * @param max defines the color remap maximal range
  67552. * @returns the current particle system
  67553. */
  67554. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67555. /**
  67556. * Not supported by GPUParticleSystem
  67557. * @param gradient defines the gradient to remove
  67558. * @returns the current particle system
  67559. */
  67560. removeColorRemapGradient(): IParticleSystem;
  67561. /**
  67562. * Not supported by GPUParticleSystem
  67563. * @param gradient defines the gradient to use (between 0 and 1)
  67564. * @param min defines the alpha remap minimal range
  67565. * @param max defines the alpha remap maximal range
  67566. * @returns the current particle system
  67567. */
  67568. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67569. /**
  67570. * Not supported by GPUParticleSystem
  67571. * @param gradient defines the gradient to remove
  67572. * @returns the current particle system
  67573. */
  67574. removeAlphaRemapGradient(): IParticleSystem;
  67575. /**
  67576. * Not supported by GPUParticleSystem
  67577. * @param gradient defines the gradient to use (between 0 and 1)
  67578. * @param color defines the color to affect to the specified gradient
  67579. * @returns the current particle system
  67580. */
  67581. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67582. /**
  67583. * Not supported by GPUParticleSystem
  67584. * @param gradient defines the gradient to remove
  67585. * @returns the current particle system
  67586. */
  67587. removeRampGradient(): IParticleSystem;
  67588. /**
  67589. * Not supported by GPUParticleSystem
  67590. * @returns the list of ramp gradients
  67591. */
  67592. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67593. /**
  67594. * Not supported by GPUParticleSystem
  67595. * Gets or sets a boolean indicating that ramp gradients must be used
  67596. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67597. */
  67598. get useRampGradients(): boolean;
  67599. set useRampGradients(value: boolean);
  67600. /**
  67601. * Not supported by GPUParticleSystem
  67602. * @param gradient defines the gradient to use (between 0 and 1)
  67603. * @param factor defines the life time factor to affect to the specified gradient
  67604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67605. * @returns the current particle system
  67606. */
  67607. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67608. /**
  67609. * Not supported by GPUParticleSystem
  67610. * @param gradient defines the gradient to remove
  67611. * @returns the current particle system
  67612. */
  67613. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67614. /**
  67615. * Instantiates a GPU particle system.
  67616. * 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.
  67617. * @param name The name of the particle system
  67618. * @param options The options used to create the system
  67619. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67620. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67621. * @param customEffect a custom effect used to change the way particles are rendered by default
  67622. */
  67623. constructor(name: string, options: Partial<{
  67624. capacity: number;
  67625. randomTextureSize: number;
  67626. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67627. protected _reset(): void;
  67628. private _createUpdateVAO;
  67629. private _createRenderVAO;
  67630. private _initialize;
  67631. /** @hidden */
  67632. _recreateUpdateEffect(): void;
  67633. private _getEffect;
  67634. /**
  67635. * Fill the defines array according to the current settings of the particle system
  67636. * @param defines Array to be updated
  67637. * @param blendMode blend mode to take into account when updating the array
  67638. */
  67639. fillDefines(defines: Array<string>, blendMode?: number): void;
  67640. /**
  67641. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67642. * @param uniforms Uniforms array to fill
  67643. * @param attributes Attributes array to fill
  67644. * @param samplers Samplers array to fill
  67645. */
  67646. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67647. /** @hidden */
  67648. _recreateRenderEffect(): Effect;
  67649. /**
  67650. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67651. * @param preWarm defines if we are in the pre-warmimg phase
  67652. */
  67653. animate(preWarm?: boolean): void;
  67654. private _createFactorGradientTexture;
  67655. private _createSizeGradientTexture;
  67656. private _createAngularSpeedGradientTexture;
  67657. private _createVelocityGradientTexture;
  67658. private _createLimitVelocityGradientTexture;
  67659. private _createDragGradientTexture;
  67660. private _createColorGradientTexture;
  67661. /**
  67662. * Renders the particle system in its current state
  67663. * @param preWarm defines if the system should only update the particles but not render them
  67664. * @returns the current number of particles
  67665. */
  67666. render(preWarm?: boolean): number;
  67667. /**
  67668. * Rebuilds the particle system
  67669. */
  67670. rebuild(): void;
  67671. private _releaseBuffers;
  67672. private _releaseVAOs;
  67673. /**
  67674. * Disposes the particle system and free the associated resources
  67675. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67676. */
  67677. dispose(disposeTexture?: boolean): void;
  67678. /**
  67679. * Clones the particle system.
  67680. * @param name The name of the cloned object
  67681. * @param newEmitter The new emitter to use
  67682. * @returns the cloned particle system
  67683. */
  67684. clone(name: string, newEmitter: any): GPUParticleSystem;
  67685. /**
  67686. * Serializes the particle system to a JSON object
  67687. * @param serializeTexture defines if the texture must be serialized as well
  67688. * @returns the JSON object
  67689. */
  67690. serialize(serializeTexture?: boolean): any;
  67691. /**
  67692. * Parses a JSON object to create a GPU particle system.
  67693. * @param parsedParticleSystem The JSON object to parse
  67694. * @param sceneOrEngine The scene or the engine to create the particle system in
  67695. * @param rootUrl The root url to use to load external dependencies like texture
  67696. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67697. * @returns the parsed GPU particle system
  67698. */
  67699. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67700. }
  67701. }
  67702. declare module BABYLON {
  67703. /**
  67704. * Represents a set of particle systems working together to create a specific effect
  67705. */
  67706. export class ParticleSystemSet implements IDisposable {
  67707. /**
  67708. * Gets or sets base Assets URL
  67709. */
  67710. static BaseAssetsUrl: string;
  67711. private _emitterCreationOptions;
  67712. private _emitterNode;
  67713. /**
  67714. * Gets the particle system list
  67715. */
  67716. systems: IParticleSystem[];
  67717. /**
  67718. * Gets the emitter node used with this set
  67719. */
  67720. get emitterNode(): Nullable<TransformNode>;
  67721. /**
  67722. * Creates a new emitter mesh as a sphere
  67723. * @param options defines the options used to create the sphere
  67724. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67725. * @param scene defines the hosting scene
  67726. */
  67727. setEmitterAsSphere(options: {
  67728. diameter: number;
  67729. segments: number;
  67730. color: Color3;
  67731. }, renderingGroupId: number, scene: Scene): void;
  67732. /**
  67733. * Starts all particle systems of the set
  67734. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67735. */
  67736. start(emitter?: AbstractMesh): void;
  67737. /**
  67738. * Release all associated resources
  67739. */
  67740. dispose(): void;
  67741. /**
  67742. * Serialize the set into a JSON compatible object
  67743. * @param serializeTexture defines if the texture must be serialized as well
  67744. * @returns a JSON compatible representation of the set
  67745. */
  67746. serialize(serializeTexture?: boolean): any;
  67747. /**
  67748. * Parse a new ParticleSystemSet from a serialized source
  67749. * @param data defines a JSON compatible representation of the set
  67750. * @param scene defines the hosting scene
  67751. * @param gpu defines if we want GPU particles or CPU particles
  67752. * @returns a new ParticleSystemSet
  67753. */
  67754. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67755. }
  67756. }
  67757. declare module BABYLON {
  67758. /**
  67759. * This class is made for on one-liner static method to help creating particle system set.
  67760. */
  67761. export class ParticleHelper {
  67762. /**
  67763. * Gets or sets base Assets URL
  67764. */
  67765. static BaseAssetsUrl: string;
  67766. /** Define the Url to load snippets */
  67767. static SnippetUrl: string;
  67768. /**
  67769. * Create a default particle system that you can tweak
  67770. * @param emitter defines the emitter to use
  67771. * @param capacity defines the system capacity (default is 500 particles)
  67772. * @param scene defines the hosting scene
  67773. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67774. * @returns the new Particle system
  67775. */
  67776. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67777. /**
  67778. * This is the main static method (one-liner) of this helper to create different particle systems
  67779. * @param type This string represents the type to the particle system to create
  67780. * @param scene The scene where the particle system should live
  67781. * @param gpu If the system will use gpu
  67782. * @returns the ParticleSystemSet created
  67783. */
  67784. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67785. /**
  67786. * Static function used to export a particle system to a ParticleSystemSet variable.
  67787. * Please note that the emitter shape is not exported
  67788. * @param systems defines the particle systems to export
  67789. * @returns the created particle system set
  67790. */
  67791. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67792. /**
  67793. * Creates a particle system from a snippet saved in a remote file
  67794. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67795. * @param url defines the url to load from
  67796. * @param scene defines the hosting scene
  67797. * @param gpu If the system will use gpu
  67798. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67799. * @returns a promise that will resolve to the new particle system
  67800. */
  67801. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67802. /**
  67803. * Creates a particle system from a snippet saved by the particle system editor
  67804. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67805. * @param scene defines the hosting scene
  67806. * @param gpu If the system will use gpu
  67807. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67808. * @returns a promise that will resolve to the new particle system
  67809. */
  67810. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67811. }
  67812. }
  67813. declare module BABYLON {
  67814. interface Engine {
  67815. /**
  67816. * Create an effect to use with particle systems.
  67817. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67818. * the particle system for which you want to create a custom effect in the last parameter
  67819. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67820. * @param uniformsNames defines a list of attribute names
  67821. * @param samplers defines an array of string used to represent textures
  67822. * @param defines defines the string containing the defines to use to compile the shaders
  67823. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67824. * @param onCompiled defines a function to call when the effect creation is successful
  67825. * @param onError defines a function to call when the effect creation has failed
  67826. * @param particleSystem the particle system you want to create the effect for
  67827. * @returns the new Effect
  67828. */
  67829. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67830. }
  67831. interface Mesh {
  67832. /**
  67833. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67834. * @returns an array of IParticleSystem
  67835. */
  67836. getEmittedParticleSystems(): IParticleSystem[];
  67837. /**
  67838. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67839. * @returns an array of IParticleSystem
  67840. */
  67841. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67842. }
  67843. }
  67844. declare module BABYLON {
  67845. /** Defines the 4 color options */
  67846. export enum PointColor {
  67847. /** color value */
  67848. Color = 2,
  67849. /** uv value */
  67850. UV = 1,
  67851. /** random value */
  67852. Random = 0,
  67853. /** stated value */
  67854. Stated = 3
  67855. }
  67856. /**
  67857. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67858. * 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.
  67859. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67860. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67861. *
  67862. * Full documentation here : TO BE ENTERED
  67863. */
  67864. export class PointsCloudSystem implements IDisposable {
  67865. /**
  67866. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67867. * Example : var p = SPS.particles[i];
  67868. */
  67869. particles: CloudPoint[];
  67870. /**
  67871. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67872. */
  67873. nbParticles: number;
  67874. /**
  67875. * This a counter for your own usage. It's not set by any SPS functions.
  67876. */
  67877. counter: number;
  67878. /**
  67879. * The PCS name. This name is also given to the underlying mesh.
  67880. */
  67881. name: string;
  67882. /**
  67883. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67884. */
  67885. mesh: Mesh;
  67886. /**
  67887. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67888. * Please read :
  67889. */
  67890. vars: any;
  67891. /**
  67892. * @hidden
  67893. */
  67894. _size: number;
  67895. private _scene;
  67896. private _promises;
  67897. private _positions;
  67898. private _indices;
  67899. private _normals;
  67900. private _colors;
  67901. private _uvs;
  67902. private _indices32;
  67903. private _positions32;
  67904. private _colors32;
  67905. private _uvs32;
  67906. private _updatable;
  67907. private _isVisibilityBoxLocked;
  67908. private _alwaysVisible;
  67909. private _groups;
  67910. private _groupCounter;
  67911. private _computeParticleColor;
  67912. private _computeParticleTexture;
  67913. private _computeParticleRotation;
  67914. private _computeBoundingBox;
  67915. private _isReady;
  67916. /**
  67917. * Creates a PCS (Points Cloud System) object
  67918. * @param name (String) is the PCS name, this will be the underlying mesh name
  67919. * @param pointSize (number) is the size for each point
  67920. * @param scene (Scene) is the scene in which the PCS is added
  67921. * @param options defines the options of the PCS e.g.
  67922. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67923. */
  67924. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67925. updatable?: boolean;
  67926. });
  67927. /**
  67928. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67929. * If no points were added to the PCS, the returned mesh is just a single point.
  67930. * @returns a promise for the created mesh
  67931. */
  67932. buildMeshAsync(): Promise<Mesh>;
  67933. /**
  67934. * @hidden
  67935. */
  67936. private _buildMesh;
  67937. private _addParticle;
  67938. private _randomUnitVector;
  67939. private _getColorIndicesForCoord;
  67940. private _setPointsColorOrUV;
  67941. private _colorFromTexture;
  67942. private _calculateDensity;
  67943. /**
  67944. * Adds points to the PCS in random positions within a unit sphere
  67945. * @param nb (positive integer) the number of particles to be created from this model
  67946. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67947. * @returns the number of groups in the system
  67948. */
  67949. addPoints(nb: number, pointFunction?: any): number;
  67950. /**
  67951. * Adds points to the PCS from the surface of the model shape
  67952. * @param mesh is any Mesh object that will be used as a surface model for the points
  67953. * @param nb (positive integer) the number of particles to be created from this model
  67954. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67955. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67956. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67957. * @returns the number of groups in the system
  67958. */
  67959. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67960. /**
  67961. * Adds points to the PCS inside the model shape
  67962. * @param mesh is any Mesh object that will be used as a surface model for the points
  67963. * @param nb (positive integer) the number of particles to be created from this model
  67964. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67965. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67966. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67967. * @returns the number of groups in the system
  67968. */
  67969. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67970. /**
  67971. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67972. * This method calls `updateParticle()` for each particle of the SPS.
  67973. * For an animated SPS, it is usually called within the render loop.
  67974. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67975. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67976. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67977. * @returns the PCS.
  67978. */
  67979. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67980. /**
  67981. * Disposes the PCS.
  67982. */
  67983. dispose(): void;
  67984. /**
  67985. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67986. * doc :
  67987. * @returns the PCS.
  67988. */
  67989. refreshVisibleSize(): PointsCloudSystem;
  67990. /**
  67991. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67992. * @param size the size (float) of the visibility box
  67993. * note : this doesn't lock the PCS mesh bounding box.
  67994. * doc :
  67995. */
  67996. setVisibilityBox(size: number): void;
  67997. /**
  67998. * Gets whether the PCS is always visible or not
  67999. * doc :
  68000. */
  68001. get isAlwaysVisible(): boolean;
  68002. /**
  68003. * Sets the PCS as always visible or not
  68004. * doc :
  68005. */
  68006. set isAlwaysVisible(val: boolean);
  68007. /**
  68008. * Tells to `setParticles()` to compute the particle rotations or not
  68009. * Default value : false. The PCS is faster when it's set to false
  68010. * Note : particle rotations are only applied to parent particles
  68011. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68012. */
  68013. set computeParticleRotation(val: boolean);
  68014. /**
  68015. * Tells to `setParticles()` to compute the particle colors or not.
  68016. * Default value : true. The PCS is faster when it's set to false.
  68017. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68018. */
  68019. set computeParticleColor(val: boolean);
  68020. set computeParticleTexture(val: boolean);
  68021. /**
  68022. * Gets if `setParticles()` computes the particle colors or not.
  68023. * Default value : false. The PCS is faster when it's set to false.
  68024. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68025. */
  68026. get computeParticleColor(): boolean;
  68027. /**
  68028. * Gets if `setParticles()` computes the particle textures or not.
  68029. * Default value : false. The PCS is faster when it's set to false.
  68030. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68031. */
  68032. get computeParticleTexture(): boolean;
  68033. /**
  68034. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68035. */
  68036. set computeBoundingBox(val: boolean);
  68037. /**
  68038. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68039. */
  68040. get computeBoundingBox(): boolean;
  68041. /**
  68042. * This function does nothing. It may be overwritten to set all the particle first values.
  68043. * The PCS doesn't call this function, you may have to call it by your own.
  68044. * doc :
  68045. */
  68046. initParticles(): void;
  68047. /**
  68048. * This function does nothing. It may be overwritten to recycle a particle
  68049. * The PCS doesn't call this function, you can to call it
  68050. * doc :
  68051. * @param particle The particle to recycle
  68052. * @returns the recycled particle
  68053. */
  68054. recycleParticle(particle: CloudPoint): CloudPoint;
  68055. /**
  68056. * Updates a particle : this function should be overwritten by the user.
  68057. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68058. * doc :
  68059. * @example : just set a particle position or velocity and recycle conditions
  68060. * @param particle The particle to update
  68061. * @returns the updated particle
  68062. */
  68063. updateParticle(particle: CloudPoint): CloudPoint;
  68064. /**
  68065. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68066. * This does nothing and may be overwritten by the user.
  68067. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68068. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68069. * @param update the boolean update value actually passed to setParticles()
  68070. */
  68071. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68072. /**
  68073. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68074. * This will be passed three parameters.
  68075. * This does nothing and may be overwritten by the user.
  68076. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68077. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68078. * @param update the boolean update value actually passed to setParticles()
  68079. */
  68080. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68081. }
  68082. }
  68083. declare module BABYLON {
  68084. /**
  68085. * Represents one particle of a points cloud system.
  68086. */
  68087. export class CloudPoint {
  68088. /**
  68089. * particle global index
  68090. */
  68091. idx: number;
  68092. /**
  68093. * The color of the particle
  68094. */
  68095. color: Nullable<Color4>;
  68096. /**
  68097. * The world space position of the particle.
  68098. */
  68099. position: Vector3;
  68100. /**
  68101. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68102. */
  68103. rotation: Vector3;
  68104. /**
  68105. * The world space rotation quaternion of the particle.
  68106. */
  68107. rotationQuaternion: Nullable<Quaternion>;
  68108. /**
  68109. * The uv of the particle.
  68110. */
  68111. uv: Nullable<Vector2>;
  68112. /**
  68113. * The current speed of the particle.
  68114. */
  68115. velocity: Vector3;
  68116. /**
  68117. * The pivot point in the particle local space.
  68118. */
  68119. pivot: Vector3;
  68120. /**
  68121. * Must the particle be translated from its pivot point in its local space ?
  68122. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68123. * Default : false
  68124. */
  68125. translateFromPivot: boolean;
  68126. /**
  68127. * Index of this particle in the global "positions" array (Internal use)
  68128. * @hidden
  68129. */
  68130. _pos: number;
  68131. /**
  68132. * @hidden Index of this particle in the global "indices" array (Internal use)
  68133. */
  68134. _ind: number;
  68135. /**
  68136. * Group this particle belongs to
  68137. */
  68138. _group: PointsGroup;
  68139. /**
  68140. * Group id of this particle
  68141. */
  68142. groupId: number;
  68143. /**
  68144. * Index of the particle in its group id (Internal use)
  68145. */
  68146. idxInGroup: number;
  68147. /**
  68148. * @hidden Particle BoundingInfo object (Internal use)
  68149. */
  68150. _boundingInfo: BoundingInfo;
  68151. /**
  68152. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68153. */
  68154. _pcs: PointsCloudSystem;
  68155. /**
  68156. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68157. */
  68158. _stillInvisible: boolean;
  68159. /**
  68160. * @hidden Last computed particle rotation matrix
  68161. */
  68162. _rotationMatrix: number[];
  68163. /**
  68164. * Parent particle Id, if any.
  68165. * Default null.
  68166. */
  68167. parentId: Nullable<number>;
  68168. /**
  68169. * @hidden Internal global position in the PCS.
  68170. */
  68171. _globalPosition: Vector3;
  68172. /**
  68173. * Creates a Point Cloud object.
  68174. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68175. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68176. * @param group (PointsGroup) is the group the particle belongs to
  68177. * @param groupId (integer) is the group identifier in the PCS.
  68178. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68179. * @param pcs defines the PCS it is associated to
  68180. */
  68181. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68182. /**
  68183. * get point size
  68184. */
  68185. get size(): Vector3;
  68186. /**
  68187. * Set point size
  68188. */
  68189. set size(scale: Vector3);
  68190. /**
  68191. * Legacy support, changed quaternion to rotationQuaternion
  68192. */
  68193. get quaternion(): Nullable<Quaternion>;
  68194. /**
  68195. * Legacy support, changed quaternion to rotationQuaternion
  68196. */
  68197. set quaternion(q: Nullable<Quaternion>);
  68198. /**
  68199. * Returns a boolean. True if the particle intersects a mesh, else false
  68200. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68201. * @param target is the object (point or mesh) what the intersection is computed against
  68202. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68203. * @returns true if it intersects
  68204. */
  68205. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68206. /**
  68207. * get the rotation matrix of the particle
  68208. * @hidden
  68209. */
  68210. getRotationMatrix(m: Matrix): void;
  68211. }
  68212. /**
  68213. * Represents a group of points in a points cloud system
  68214. * * PCS internal tool, don't use it manually.
  68215. */
  68216. export class PointsGroup {
  68217. /**
  68218. * The group id
  68219. * @hidden
  68220. */
  68221. groupID: number;
  68222. /**
  68223. * image data for group (internal use)
  68224. * @hidden
  68225. */
  68226. _groupImageData: Nullable<ArrayBufferView>;
  68227. /**
  68228. * Image Width (internal use)
  68229. * @hidden
  68230. */
  68231. _groupImgWidth: number;
  68232. /**
  68233. * Image Height (internal use)
  68234. * @hidden
  68235. */
  68236. _groupImgHeight: number;
  68237. /**
  68238. * Custom position function (internal use)
  68239. * @hidden
  68240. */
  68241. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68242. /**
  68243. * density per facet for surface points
  68244. * @hidden
  68245. */
  68246. _groupDensity: number[];
  68247. /**
  68248. * Only when points are colored by texture carries pointer to texture list array
  68249. * @hidden
  68250. */
  68251. _textureNb: number;
  68252. /**
  68253. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68254. * PCS internal tool, don't use it manually.
  68255. * @hidden
  68256. */
  68257. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68258. }
  68259. }
  68260. declare module BABYLON {
  68261. interface Scene {
  68262. /** @hidden (Backing field) */
  68263. _physicsEngine: Nullable<IPhysicsEngine>;
  68264. /** @hidden */
  68265. _physicsTimeAccumulator: number;
  68266. /**
  68267. * Gets the current physics engine
  68268. * @returns a IPhysicsEngine or null if none attached
  68269. */
  68270. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68271. /**
  68272. * Enables physics to the current scene
  68273. * @param gravity defines the scene's gravity for the physics engine
  68274. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68275. * @return a boolean indicating if the physics engine was initialized
  68276. */
  68277. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68278. /**
  68279. * Disables and disposes the physics engine associated with the scene
  68280. */
  68281. disablePhysicsEngine(): void;
  68282. /**
  68283. * Gets a boolean indicating if there is an active physics engine
  68284. * @returns a boolean indicating if there is an active physics engine
  68285. */
  68286. isPhysicsEnabled(): boolean;
  68287. /**
  68288. * Deletes a physics compound impostor
  68289. * @param compound defines the compound to delete
  68290. */
  68291. deleteCompoundImpostor(compound: any): void;
  68292. /**
  68293. * An event triggered when physic simulation is about to be run
  68294. */
  68295. onBeforePhysicsObservable: Observable<Scene>;
  68296. /**
  68297. * An event triggered when physic simulation has been done
  68298. */
  68299. onAfterPhysicsObservable: Observable<Scene>;
  68300. }
  68301. interface AbstractMesh {
  68302. /** @hidden */
  68303. _physicsImpostor: Nullable<PhysicsImpostor>;
  68304. /**
  68305. * Gets or sets impostor used for physic simulation
  68306. * @see https://doc.babylonjs.com/features/physics_engine
  68307. */
  68308. physicsImpostor: Nullable<PhysicsImpostor>;
  68309. /**
  68310. * Gets the current physics impostor
  68311. * @see https://doc.babylonjs.com/features/physics_engine
  68312. * @returns a physics impostor or null
  68313. */
  68314. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68315. /** Apply a physic impulse to the mesh
  68316. * @param force defines the force to apply
  68317. * @param contactPoint defines where to apply the force
  68318. * @returns the current mesh
  68319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68320. */
  68321. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68322. /**
  68323. * Creates a physic joint between two meshes
  68324. * @param otherMesh defines the other mesh to use
  68325. * @param pivot1 defines the pivot to use on this mesh
  68326. * @param pivot2 defines the pivot to use on the other mesh
  68327. * @param options defines additional options (can be plugin dependent)
  68328. * @returns the current mesh
  68329. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68330. */
  68331. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68332. /** @hidden */
  68333. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68334. }
  68335. /**
  68336. * Defines the physics engine scene component responsible to manage a physics engine
  68337. */
  68338. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68339. /**
  68340. * The component name helpful to identify the component in the list of scene components.
  68341. */
  68342. readonly name: string;
  68343. /**
  68344. * The scene the component belongs to.
  68345. */
  68346. scene: Scene;
  68347. /**
  68348. * Creates a new instance of the component for the given scene
  68349. * @param scene Defines the scene to register the component in
  68350. */
  68351. constructor(scene: Scene);
  68352. /**
  68353. * Registers the component in a given scene
  68354. */
  68355. register(): void;
  68356. /**
  68357. * Rebuilds the elements related to this component in case of
  68358. * context lost for instance.
  68359. */
  68360. rebuild(): void;
  68361. /**
  68362. * Disposes the component and the associated ressources
  68363. */
  68364. dispose(): void;
  68365. }
  68366. }
  68367. declare module BABYLON {
  68368. /**
  68369. * A helper for physics simulations
  68370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68371. */
  68372. export class PhysicsHelper {
  68373. private _scene;
  68374. private _physicsEngine;
  68375. /**
  68376. * Initializes the Physics helper
  68377. * @param scene Babylon.js scene
  68378. */
  68379. constructor(scene: Scene);
  68380. /**
  68381. * Applies a radial explosion impulse
  68382. * @param origin the origin of the explosion
  68383. * @param radiusOrEventOptions the radius or the options of radial explosion
  68384. * @param strength the explosion strength
  68385. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68386. * @returns A physics radial explosion event, or null
  68387. */
  68388. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68389. /**
  68390. * Applies a radial explosion force
  68391. * @param origin the origin of the explosion
  68392. * @param radiusOrEventOptions the radius or the options of radial explosion
  68393. * @param strength the explosion strength
  68394. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68395. * @returns A physics radial explosion event, or null
  68396. */
  68397. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68398. /**
  68399. * Creates a gravitational field
  68400. * @param origin the origin of the explosion
  68401. * @param radiusOrEventOptions the radius or the options of radial explosion
  68402. * @param strength the explosion strength
  68403. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68404. * @returns A physics gravitational field event, or null
  68405. */
  68406. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68407. /**
  68408. * Creates a physics updraft event
  68409. * @param origin the origin of the updraft
  68410. * @param radiusOrEventOptions the radius or the options of the updraft
  68411. * @param strength the strength of the updraft
  68412. * @param height the height of the updraft
  68413. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68414. * @returns A physics updraft event, or null
  68415. */
  68416. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68417. /**
  68418. * Creates a physics vortex event
  68419. * @param origin the of the vortex
  68420. * @param radiusOrEventOptions the radius or the options of the vortex
  68421. * @param strength the strength of the vortex
  68422. * @param height the height of the vortex
  68423. * @returns a Physics vortex event, or null
  68424. * A physics vortex event or null
  68425. */
  68426. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68427. }
  68428. /**
  68429. * Represents a physics radial explosion event
  68430. */
  68431. class PhysicsRadialExplosionEvent {
  68432. private _scene;
  68433. private _options;
  68434. private _sphere;
  68435. private _dataFetched;
  68436. /**
  68437. * Initializes a radial explosioin event
  68438. * @param _scene BabylonJS scene
  68439. * @param _options The options for the vortex event
  68440. */
  68441. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68442. /**
  68443. * Returns the data related to the radial explosion event (sphere).
  68444. * @returns The radial explosion event data
  68445. */
  68446. getData(): PhysicsRadialExplosionEventData;
  68447. /**
  68448. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68449. * @param impostor A physics imposter
  68450. * @param origin the origin of the explosion
  68451. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68452. */
  68453. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68454. /**
  68455. * Triggers affecterd impostors callbacks
  68456. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68457. */
  68458. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68459. /**
  68460. * Disposes the sphere.
  68461. * @param force Specifies if the sphere should be disposed by force
  68462. */
  68463. dispose(force?: boolean): void;
  68464. /*** Helpers ***/
  68465. private _prepareSphere;
  68466. private _intersectsWithSphere;
  68467. }
  68468. /**
  68469. * Represents a gravitational field event
  68470. */
  68471. class PhysicsGravitationalFieldEvent {
  68472. private _physicsHelper;
  68473. private _scene;
  68474. private _origin;
  68475. private _options;
  68476. private _tickCallback;
  68477. private _sphere;
  68478. private _dataFetched;
  68479. /**
  68480. * Initializes the physics gravitational field event
  68481. * @param _physicsHelper A physics helper
  68482. * @param _scene BabylonJS scene
  68483. * @param _origin The origin position of the gravitational field event
  68484. * @param _options The options for the vortex event
  68485. */
  68486. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68487. /**
  68488. * Returns the data related to the gravitational field event (sphere).
  68489. * @returns A gravitational field event
  68490. */
  68491. getData(): PhysicsGravitationalFieldEventData;
  68492. /**
  68493. * Enables the gravitational field.
  68494. */
  68495. enable(): void;
  68496. /**
  68497. * Disables the gravitational field.
  68498. */
  68499. disable(): void;
  68500. /**
  68501. * Disposes the sphere.
  68502. * @param force The force to dispose from the gravitational field event
  68503. */
  68504. dispose(force?: boolean): void;
  68505. private _tick;
  68506. }
  68507. /**
  68508. * Represents a physics updraft event
  68509. */
  68510. class PhysicsUpdraftEvent {
  68511. private _scene;
  68512. private _origin;
  68513. private _options;
  68514. private _physicsEngine;
  68515. private _originTop;
  68516. private _originDirection;
  68517. private _tickCallback;
  68518. private _cylinder;
  68519. private _cylinderPosition;
  68520. private _dataFetched;
  68521. /**
  68522. * Initializes the physics updraft event
  68523. * @param _scene BabylonJS scene
  68524. * @param _origin The origin position of the updraft
  68525. * @param _options The options for the updraft event
  68526. */
  68527. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68528. /**
  68529. * Returns the data related to the updraft event (cylinder).
  68530. * @returns A physics updraft event
  68531. */
  68532. getData(): PhysicsUpdraftEventData;
  68533. /**
  68534. * Enables the updraft.
  68535. */
  68536. enable(): void;
  68537. /**
  68538. * Disables the updraft.
  68539. */
  68540. disable(): void;
  68541. /**
  68542. * Disposes the cylinder.
  68543. * @param force Specifies if the updraft should be disposed by force
  68544. */
  68545. dispose(force?: boolean): void;
  68546. private getImpostorHitData;
  68547. private _tick;
  68548. /*** Helpers ***/
  68549. private _prepareCylinder;
  68550. private _intersectsWithCylinder;
  68551. }
  68552. /**
  68553. * Represents a physics vortex event
  68554. */
  68555. class PhysicsVortexEvent {
  68556. private _scene;
  68557. private _origin;
  68558. private _options;
  68559. private _physicsEngine;
  68560. private _originTop;
  68561. private _tickCallback;
  68562. private _cylinder;
  68563. private _cylinderPosition;
  68564. private _dataFetched;
  68565. /**
  68566. * Initializes the physics vortex event
  68567. * @param _scene The BabylonJS scene
  68568. * @param _origin The origin position of the vortex
  68569. * @param _options The options for the vortex event
  68570. */
  68571. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68572. /**
  68573. * Returns the data related to the vortex event (cylinder).
  68574. * @returns The physics vortex event data
  68575. */
  68576. getData(): PhysicsVortexEventData;
  68577. /**
  68578. * Enables the vortex.
  68579. */
  68580. enable(): void;
  68581. /**
  68582. * Disables the cortex.
  68583. */
  68584. disable(): void;
  68585. /**
  68586. * Disposes the sphere.
  68587. * @param force
  68588. */
  68589. dispose(force?: boolean): void;
  68590. private getImpostorHitData;
  68591. private _tick;
  68592. /*** Helpers ***/
  68593. private _prepareCylinder;
  68594. private _intersectsWithCylinder;
  68595. }
  68596. /**
  68597. * Options fot the radial explosion event
  68598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68599. */
  68600. export class PhysicsRadialExplosionEventOptions {
  68601. /**
  68602. * The radius of the sphere for the radial explosion.
  68603. */
  68604. radius: number;
  68605. /**
  68606. * The strenth of the explosion.
  68607. */
  68608. strength: number;
  68609. /**
  68610. * The strenght of the force in correspondence to the distance of the affected object
  68611. */
  68612. falloff: PhysicsRadialImpulseFalloff;
  68613. /**
  68614. * Sphere options for the radial explosion.
  68615. */
  68616. sphere: {
  68617. segments: number;
  68618. diameter: number;
  68619. };
  68620. /**
  68621. * Sphere options for the radial explosion.
  68622. */
  68623. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68624. }
  68625. /**
  68626. * Options fot the updraft event
  68627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68628. */
  68629. export class PhysicsUpdraftEventOptions {
  68630. /**
  68631. * The radius of the cylinder for the vortex
  68632. */
  68633. radius: number;
  68634. /**
  68635. * The strenth of the updraft.
  68636. */
  68637. strength: number;
  68638. /**
  68639. * The height of the cylinder for the updraft.
  68640. */
  68641. height: number;
  68642. /**
  68643. * The mode for the the updraft.
  68644. */
  68645. updraftMode: PhysicsUpdraftMode;
  68646. }
  68647. /**
  68648. * Options fot the vortex event
  68649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68650. */
  68651. export class PhysicsVortexEventOptions {
  68652. /**
  68653. * The radius of the cylinder for the vortex
  68654. */
  68655. radius: number;
  68656. /**
  68657. * The strenth of the vortex.
  68658. */
  68659. strength: number;
  68660. /**
  68661. * The height of the cylinder for the vortex.
  68662. */
  68663. height: number;
  68664. /**
  68665. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68666. */
  68667. centripetalForceThreshold: number;
  68668. /**
  68669. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68670. */
  68671. centripetalForceMultiplier: number;
  68672. /**
  68673. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68674. */
  68675. centrifugalForceMultiplier: number;
  68676. /**
  68677. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68678. */
  68679. updraftForceMultiplier: number;
  68680. }
  68681. /**
  68682. * The strenght of the force in correspondence to the distance of the affected object
  68683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68684. */
  68685. export enum PhysicsRadialImpulseFalloff {
  68686. /** Defines that impulse is constant in strength across it's whole radius */
  68687. Constant = 0,
  68688. /** Defines that impulse gets weaker if it's further from the origin */
  68689. Linear = 1
  68690. }
  68691. /**
  68692. * The strength of the force in correspondence to the distance of the affected object
  68693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68694. */
  68695. export enum PhysicsUpdraftMode {
  68696. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68697. Center = 0,
  68698. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68699. Perpendicular = 1
  68700. }
  68701. /**
  68702. * Interface for a physics hit data
  68703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68704. */
  68705. export interface PhysicsHitData {
  68706. /**
  68707. * The force applied at the contact point
  68708. */
  68709. force: Vector3;
  68710. /**
  68711. * The contact point
  68712. */
  68713. contactPoint: Vector3;
  68714. /**
  68715. * The distance from the origin to the contact point
  68716. */
  68717. distanceFromOrigin: number;
  68718. }
  68719. /**
  68720. * Interface for radial explosion event data
  68721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68722. */
  68723. export interface PhysicsRadialExplosionEventData {
  68724. /**
  68725. * A sphere used for the radial explosion event
  68726. */
  68727. sphere: Mesh;
  68728. }
  68729. /**
  68730. * Interface for gravitational field event data
  68731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68732. */
  68733. export interface PhysicsGravitationalFieldEventData {
  68734. /**
  68735. * A sphere mesh used for the gravitational field event
  68736. */
  68737. sphere: Mesh;
  68738. }
  68739. /**
  68740. * Interface for updraft event data
  68741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68742. */
  68743. export interface PhysicsUpdraftEventData {
  68744. /**
  68745. * A cylinder used for the updraft event
  68746. */
  68747. cylinder: Mesh;
  68748. }
  68749. /**
  68750. * Interface for vortex event data
  68751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68752. */
  68753. export interface PhysicsVortexEventData {
  68754. /**
  68755. * A cylinder used for the vortex event
  68756. */
  68757. cylinder: Mesh;
  68758. }
  68759. /**
  68760. * Interface for an affected physics impostor
  68761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68762. */
  68763. export interface PhysicsAffectedImpostorWithData {
  68764. /**
  68765. * The impostor affected by the effect
  68766. */
  68767. impostor: PhysicsImpostor;
  68768. /**
  68769. * The data about the hit/horce from the explosion
  68770. */
  68771. hitData: PhysicsHitData;
  68772. }
  68773. }
  68774. declare module BABYLON {
  68775. /** @hidden */
  68776. export var blackAndWhitePixelShader: {
  68777. name: string;
  68778. shader: string;
  68779. };
  68780. }
  68781. declare module BABYLON {
  68782. /**
  68783. * Post process used to render in black and white
  68784. */
  68785. export class BlackAndWhitePostProcess extends PostProcess {
  68786. /**
  68787. * Linear about to convert he result to black and white (default: 1)
  68788. */
  68789. degree: number;
  68790. /**
  68791. * Gets a string identifying the name of the class
  68792. * @returns "BlackAndWhitePostProcess" string
  68793. */
  68794. getClassName(): string;
  68795. /**
  68796. * Creates a black and white post process
  68797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68798. * @param name The name of the effect.
  68799. * @param options The required width/height ratio to downsize to before computing the render pass.
  68800. * @param camera The camera to apply the render pass to.
  68801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68802. * @param engine The engine which the post process will be applied. (default: current engine)
  68803. * @param reusable If the post process can be reused on the same frame. (default: false)
  68804. */
  68805. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68806. /** @hidden */
  68807. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68808. }
  68809. }
  68810. declare module BABYLON {
  68811. /**
  68812. * This represents a set of one or more post processes in Babylon.
  68813. * A post process can be used to apply a shader to a texture after it is rendered.
  68814. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68815. */
  68816. export class PostProcessRenderEffect {
  68817. private _postProcesses;
  68818. private _getPostProcesses;
  68819. private _singleInstance;
  68820. private _cameras;
  68821. private _indicesForCamera;
  68822. /**
  68823. * Name of the effect
  68824. * @hidden
  68825. */
  68826. _name: string;
  68827. /**
  68828. * Instantiates a post process render effect.
  68829. * A post process can be used to apply a shader to a texture after it is rendered.
  68830. * @param engine The engine the effect is tied to
  68831. * @param name The name of the effect
  68832. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68833. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68834. */
  68835. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68836. /**
  68837. * Checks if all the post processes in the effect are supported.
  68838. */
  68839. get isSupported(): boolean;
  68840. /**
  68841. * Updates the current state of the effect
  68842. * @hidden
  68843. */
  68844. _update(): void;
  68845. /**
  68846. * Attaches the effect on cameras
  68847. * @param cameras The camera to attach to.
  68848. * @hidden
  68849. */
  68850. _attachCameras(cameras: Camera): void;
  68851. /**
  68852. * Attaches the effect on cameras
  68853. * @param cameras The camera to attach to.
  68854. * @hidden
  68855. */
  68856. _attachCameras(cameras: Camera[]): void;
  68857. /**
  68858. * Detaches the effect on cameras
  68859. * @param cameras The camera to detatch from.
  68860. * @hidden
  68861. */
  68862. _detachCameras(cameras: Camera): void;
  68863. /**
  68864. * Detatches the effect on cameras
  68865. * @param cameras The camera to detatch from.
  68866. * @hidden
  68867. */
  68868. _detachCameras(cameras: Camera[]): void;
  68869. /**
  68870. * Enables the effect on given cameras
  68871. * @param cameras The camera to enable.
  68872. * @hidden
  68873. */
  68874. _enable(cameras: Camera): void;
  68875. /**
  68876. * Enables the effect on given cameras
  68877. * @param cameras The camera to enable.
  68878. * @hidden
  68879. */
  68880. _enable(cameras: Nullable<Camera[]>): void;
  68881. /**
  68882. * Disables the effect on the given cameras
  68883. * @param cameras The camera to disable.
  68884. * @hidden
  68885. */
  68886. _disable(cameras: Camera): void;
  68887. /**
  68888. * Disables the effect on the given cameras
  68889. * @param cameras The camera to disable.
  68890. * @hidden
  68891. */
  68892. _disable(cameras: Nullable<Camera[]>): void;
  68893. /**
  68894. * Gets a list of the post processes contained in the effect.
  68895. * @param camera The camera to get the post processes on.
  68896. * @returns The list of the post processes in the effect.
  68897. */
  68898. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68899. }
  68900. }
  68901. declare module BABYLON {
  68902. /** @hidden */
  68903. export var extractHighlightsPixelShader: {
  68904. name: string;
  68905. shader: string;
  68906. };
  68907. }
  68908. declare module BABYLON {
  68909. /**
  68910. * 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.
  68911. */
  68912. export class ExtractHighlightsPostProcess extends PostProcess {
  68913. /**
  68914. * The luminance threshold, pixels below this value will be set to black.
  68915. */
  68916. threshold: number;
  68917. /** @hidden */
  68918. _exposure: number;
  68919. /**
  68920. * Post process which has the input texture to be used when performing highlight extraction
  68921. * @hidden
  68922. */
  68923. _inputPostProcess: Nullable<PostProcess>;
  68924. /**
  68925. * Gets a string identifying the name of the class
  68926. * @returns "ExtractHighlightsPostProcess" string
  68927. */
  68928. getClassName(): string;
  68929. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68930. }
  68931. }
  68932. declare module BABYLON {
  68933. /** @hidden */
  68934. export var bloomMergePixelShader: {
  68935. name: string;
  68936. shader: string;
  68937. };
  68938. }
  68939. declare module BABYLON {
  68940. /**
  68941. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68942. */
  68943. export class BloomMergePostProcess extends PostProcess {
  68944. /** Weight of the bloom to be added to the original input. */
  68945. weight: number;
  68946. /**
  68947. * Gets a string identifying the name of the class
  68948. * @returns "BloomMergePostProcess" string
  68949. */
  68950. getClassName(): string;
  68951. /**
  68952. * Creates a new instance of @see BloomMergePostProcess
  68953. * @param name The name of the effect.
  68954. * @param originalFromInput Post process which's input will be used for the merge.
  68955. * @param blurred Blurred highlights post process which's output will be used.
  68956. * @param weight Weight of the bloom to be added to the original input.
  68957. * @param options The required width/height ratio to downsize to before computing the render pass.
  68958. * @param camera The camera to apply the render pass to.
  68959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68960. * @param engine The engine which the post process will be applied. (default: current engine)
  68961. * @param reusable If the post process can be reused on the same frame. (default: false)
  68962. * @param textureType Type of textures used when performing the post process. (default: 0)
  68963. * @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)
  68964. */
  68965. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68966. /** Weight of the bloom to be added to the original input. */
  68967. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68968. }
  68969. }
  68970. declare module BABYLON {
  68971. /**
  68972. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68973. */
  68974. export class BloomEffect extends PostProcessRenderEffect {
  68975. private bloomScale;
  68976. /**
  68977. * @hidden Internal
  68978. */
  68979. _effects: Array<PostProcess>;
  68980. /**
  68981. * @hidden Internal
  68982. */
  68983. _downscale: ExtractHighlightsPostProcess;
  68984. private _blurX;
  68985. private _blurY;
  68986. private _merge;
  68987. /**
  68988. * The luminance threshold to find bright areas of the image to bloom.
  68989. */
  68990. get threshold(): number;
  68991. set threshold(value: number);
  68992. /**
  68993. * The strength of the bloom.
  68994. */
  68995. get weight(): number;
  68996. set weight(value: number);
  68997. /**
  68998. * Specifies the size of the bloom blur kernel, relative to the final output size
  68999. */
  69000. get kernel(): number;
  69001. set kernel(value: number);
  69002. /**
  69003. * Creates a new instance of @see BloomEffect
  69004. * @param scene The scene the effect belongs to.
  69005. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69006. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69007. * @param bloomWeight The the strength of bloom.
  69008. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69009. * @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)
  69010. */
  69011. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69012. /**
  69013. * Disposes each of the internal effects for a given camera.
  69014. * @param camera The camera to dispose the effect on.
  69015. */
  69016. disposeEffects(camera: Camera): void;
  69017. /**
  69018. * @hidden Internal
  69019. */
  69020. _updateEffects(): void;
  69021. /**
  69022. * Internal
  69023. * @returns if all the contained post processes are ready.
  69024. * @hidden
  69025. */
  69026. _isReady(): boolean;
  69027. }
  69028. }
  69029. declare module BABYLON {
  69030. /** @hidden */
  69031. export var chromaticAberrationPixelShader: {
  69032. name: string;
  69033. shader: string;
  69034. };
  69035. }
  69036. declare module BABYLON {
  69037. /**
  69038. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69039. */
  69040. export class ChromaticAberrationPostProcess extends PostProcess {
  69041. /**
  69042. * The amount of seperation of rgb channels (default: 30)
  69043. */
  69044. aberrationAmount: number;
  69045. /**
  69046. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69047. */
  69048. radialIntensity: number;
  69049. /**
  69050. * 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))
  69051. */
  69052. direction: Vector2;
  69053. /**
  69054. * 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))
  69055. */
  69056. centerPosition: Vector2;
  69057. /** The width of the screen to apply the effect on */
  69058. screenWidth: number;
  69059. /** The height of the screen to apply the effect on */
  69060. screenHeight: number;
  69061. /**
  69062. * Gets a string identifying the name of the class
  69063. * @returns "ChromaticAberrationPostProcess" string
  69064. */
  69065. getClassName(): string;
  69066. /**
  69067. * Creates a new instance ChromaticAberrationPostProcess
  69068. * @param name The name of the effect.
  69069. * @param screenWidth The width of the screen to apply the effect on.
  69070. * @param screenHeight The height of the screen to apply the effect on.
  69071. * @param options The required width/height ratio to downsize to before computing the render pass.
  69072. * @param camera The camera to apply the render pass to.
  69073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69074. * @param engine The engine which the post process will be applied. (default: current engine)
  69075. * @param reusable If the post process can be reused on the same frame. (default: false)
  69076. * @param textureType Type of textures used when performing the post process. (default: 0)
  69077. * @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)
  69078. */
  69079. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69080. /** @hidden */
  69081. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69082. }
  69083. }
  69084. declare module BABYLON {
  69085. /** @hidden */
  69086. export var circleOfConfusionPixelShader: {
  69087. name: string;
  69088. shader: string;
  69089. };
  69090. }
  69091. declare module BABYLON {
  69092. /**
  69093. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69094. */
  69095. export class CircleOfConfusionPostProcess extends PostProcess {
  69096. /**
  69097. * 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.
  69098. */
  69099. lensSize: number;
  69100. /**
  69101. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69102. */
  69103. fStop: number;
  69104. /**
  69105. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69106. */
  69107. focusDistance: number;
  69108. /**
  69109. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69110. */
  69111. focalLength: number;
  69112. /**
  69113. * Gets a string identifying the name of the class
  69114. * @returns "CircleOfConfusionPostProcess" string
  69115. */
  69116. getClassName(): string;
  69117. private _depthTexture;
  69118. /**
  69119. * Creates a new instance CircleOfConfusionPostProcess
  69120. * @param name The name of the effect.
  69121. * @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.
  69122. * @param options The required width/height ratio to downsize to before computing the render pass.
  69123. * @param camera The camera to apply the render pass to.
  69124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69125. * @param engine The engine which the post process will be applied. (default: current engine)
  69126. * @param reusable If the post process can be reused on the same frame. (default: false)
  69127. * @param textureType Type of textures used when performing the post process. (default: 0)
  69128. * @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)
  69129. */
  69130. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69131. /**
  69132. * 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.
  69133. */
  69134. set depthTexture(value: RenderTargetTexture);
  69135. }
  69136. }
  69137. declare module BABYLON {
  69138. /** @hidden */
  69139. export var colorCorrectionPixelShader: {
  69140. name: string;
  69141. shader: string;
  69142. };
  69143. }
  69144. declare module BABYLON {
  69145. /**
  69146. *
  69147. * This post-process allows the modification of rendered colors by using
  69148. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69149. *
  69150. * The object needs to be provided an url to a texture containing the color
  69151. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69152. * Use an image editing software to tweak the LUT to match your needs.
  69153. *
  69154. * For an example of a color LUT, see here:
  69155. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69156. * For explanations on color grading, see here:
  69157. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69158. *
  69159. */
  69160. export class ColorCorrectionPostProcess extends PostProcess {
  69161. private _colorTableTexture;
  69162. /**
  69163. * Gets the color table url used to create the LUT texture
  69164. */
  69165. colorTableUrl: string;
  69166. /**
  69167. * Gets a string identifying the name of the class
  69168. * @returns "ColorCorrectionPostProcess" string
  69169. */
  69170. getClassName(): string;
  69171. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69172. /** @hidden */
  69173. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69174. }
  69175. }
  69176. declare module BABYLON {
  69177. /** @hidden */
  69178. export var convolutionPixelShader: {
  69179. name: string;
  69180. shader: string;
  69181. };
  69182. }
  69183. declare module BABYLON {
  69184. /**
  69185. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69186. * input texture to perform effects such as edge detection or sharpening
  69187. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69188. */
  69189. export class ConvolutionPostProcess extends PostProcess {
  69190. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69191. kernel: number[];
  69192. /**
  69193. * Gets a string identifying the name of the class
  69194. * @returns "ConvolutionPostProcess" string
  69195. */
  69196. getClassName(): string;
  69197. /**
  69198. * Creates a new instance ConvolutionPostProcess
  69199. * @param name The name of the effect.
  69200. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69201. * @param options The required width/height ratio to downsize to before computing the render pass.
  69202. * @param camera The camera to apply the render pass to.
  69203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69204. * @param engine The engine which the post process will be applied. (default: current engine)
  69205. * @param reusable If the post process can be reused on the same frame. (default: false)
  69206. * @param textureType Type of textures used when performing the post process. (default: 0)
  69207. */
  69208. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69209. /** @hidden */
  69210. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69211. /**
  69212. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69213. */
  69214. static EdgeDetect0Kernel: number[];
  69215. /**
  69216. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69217. */
  69218. static EdgeDetect1Kernel: number[];
  69219. /**
  69220. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69221. */
  69222. static EdgeDetect2Kernel: number[];
  69223. /**
  69224. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69225. */
  69226. static SharpenKernel: number[];
  69227. /**
  69228. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69229. */
  69230. static EmbossKernel: number[];
  69231. /**
  69232. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69233. */
  69234. static GaussianKernel: number[];
  69235. }
  69236. }
  69237. declare module BABYLON {
  69238. /**
  69239. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69240. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69241. * based on samples that have a large difference in distance than the center pixel.
  69242. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69243. */
  69244. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69245. /**
  69246. * The direction the blur should be applied
  69247. */
  69248. direction: Vector2;
  69249. /**
  69250. * Gets a string identifying the name of the class
  69251. * @returns "DepthOfFieldBlurPostProcess" string
  69252. */
  69253. getClassName(): string;
  69254. /**
  69255. * Creates a new instance CircleOfConfusionPostProcess
  69256. * @param name The name of the effect.
  69257. * @param scene The scene the effect belongs to.
  69258. * @param direction The direction the blur should be applied.
  69259. * @param kernel The size of the kernel used to blur.
  69260. * @param options The required width/height ratio to downsize to before computing the render pass.
  69261. * @param camera The camera to apply the render pass to.
  69262. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69263. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69265. * @param engine The engine which the post process will be applied. (default: current engine)
  69266. * @param reusable If the post process can be reused on the same frame. (default: false)
  69267. * @param textureType Type of textures used when performing the post process. (default: 0)
  69268. * @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)
  69269. */
  69270. 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);
  69271. }
  69272. }
  69273. declare module BABYLON {
  69274. /** @hidden */
  69275. export var depthOfFieldMergePixelShader: {
  69276. name: string;
  69277. shader: string;
  69278. };
  69279. }
  69280. declare module BABYLON {
  69281. /**
  69282. * Options to be set when merging outputs from the default pipeline.
  69283. */
  69284. export class DepthOfFieldMergePostProcessOptions {
  69285. /**
  69286. * The original image to merge on top of
  69287. */
  69288. originalFromInput: PostProcess;
  69289. /**
  69290. * Parameters to perform the merge of the depth of field effect
  69291. */
  69292. depthOfField?: {
  69293. circleOfConfusion: PostProcess;
  69294. blurSteps: Array<PostProcess>;
  69295. };
  69296. /**
  69297. * Parameters to perform the merge of bloom effect
  69298. */
  69299. bloom?: {
  69300. blurred: PostProcess;
  69301. weight: number;
  69302. };
  69303. }
  69304. /**
  69305. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69306. */
  69307. export class DepthOfFieldMergePostProcess extends PostProcess {
  69308. private blurSteps;
  69309. /**
  69310. * Gets a string identifying the name of the class
  69311. * @returns "DepthOfFieldMergePostProcess" string
  69312. */
  69313. getClassName(): string;
  69314. /**
  69315. * Creates a new instance of DepthOfFieldMergePostProcess
  69316. * @param name The name of the effect.
  69317. * @param originalFromInput Post process which's input will be used for the merge.
  69318. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69319. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69320. * @param options The required width/height ratio to downsize to before computing the render pass.
  69321. * @param camera The camera to apply the render pass to.
  69322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69323. * @param engine The engine which the post process will be applied. (default: current engine)
  69324. * @param reusable If the post process can be reused on the same frame. (default: false)
  69325. * @param textureType Type of textures used when performing the post process. (default: 0)
  69326. * @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)
  69327. */
  69328. 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);
  69329. /**
  69330. * Updates the effect with the current post process compile time values and recompiles the shader.
  69331. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69332. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69333. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69334. * @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
  69335. * @param onCompiled Called when the shader has been compiled.
  69336. * @param onError Called if there is an error when compiling a shader.
  69337. */
  69338. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69339. }
  69340. }
  69341. declare module BABYLON {
  69342. /**
  69343. * Specifies the level of max blur that should be applied when using the depth of field effect
  69344. */
  69345. export enum DepthOfFieldEffectBlurLevel {
  69346. /**
  69347. * Subtle blur
  69348. */
  69349. Low = 0,
  69350. /**
  69351. * Medium blur
  69352. */
  69353. Medium = 1,
  69354. /**
  69355. * Large blur
  69356. */
  69357. High = 2
  69358. }
  69359. /**
  69360. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69361. */
  69362. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69363. private _circleOfConfusion;
  69364. /**
  69365. * @hidden Internal, blurs from high to low
  69366. */
  69367. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69368. private _depthOfFieldBlurY;
  69369. private _dofMerge;
  69370. /**
  69371. * @hidden Internal post processes in depth of field effect
  69372. */
  69373. _effects: Array<PostProcess>;
  69374. /**
  69375. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69376. */
  69377. set focalLength(value: number);
  69378. get focalLength(): number;
  69379. /**
  69380. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69381. */
  69382. set fStop(value: number);
  69383. get fStop(): number;
  69384. /**
  69385. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69386. */
  69387. set focusDistance(value: number);
  69388. get focusDistance(): number;
  69389. /**
  69390. * 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.
  69391. */
  69392. set lensSize(value: number);
  69393. get lensSize(): number;
  69394. /**
  69395. * Creates a new instance DepthOfFieldEffect
  69396. * @param scene The scene the effect belongs to.
  69397. * @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.
  69398. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69399. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  69400. */
  69401. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69402. /**
  69403. * Get the current class name of the current effet
  69404. * @returns "DepthOfFieldEffect"
  69405. */
  69406. getClassName(): string;
  69407. /**
  69408. * 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.
  69409. */
  69410. set depthTexture(value: RenderTargetTexture);
  69411. /**
  69412. * Disposes each of the internal effects for a given camera.
  69413. * @param camera The camera to dispose the effect on.
  69414. */
  69415. disposeEffects(camera: Camera): void;
  69416. /**
  69417. * @hidden Internal
  69418. */
  69419. _updateEffects(): void;
  69420. /**
  69421. * Internal
  69422. * @returns if all the contained post processes are ready.
  69423. * @hidden
  69424. */
  69425. _isReady(): boolean;
  69426. }
  69427. }
  69428. declare module BABYLON {
  69429. /** @hidden */
  69430. export var displayPassPixelShader: {
  69431. name: string;
  69432. shader: string;
  69433. };
  69434. }
  69435. declare module BABYLON {
  69436. /**
  69437. * DisplayPassPostProcess which produces an output the same as it's input
  69438. */
  69439. export class DisplayPassPostProcess extends PostProcess {
  69440. /**
  69441. * Gets a string identifying the name of the class
  69442. * @returns "DisplayPassPostProcess" string
  69443. */
  69444. getClassName(): string;
  69445. /**
  69446. * Creates the DisplayPassPostProcess
  69447. * @param name The name of the effect.
  69448. * @param options The required width/height ratio to downsize to before computing the render pass.
  69449. * @param camera The camera to apply the render pass to.
  69450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69451. * @param engine The engine which the post process will be applied. (default: current engine)
  69452. * @param reusable If the post process can be reused on the same frame. (default: false)
  69453. */
  69454. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69455. /** @hidden */
  69456. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69457. }
  69458. }
  69459. declare module BABYLON {
  69460. /** @hidden */
  69461. export var filterPixelShader: {
  69462. name: string;
  69463. shader: string;
  69464. };
  69465. }
  69466. declare module BABYLON {
  69467. /**
  69468. * Applies a kernel filter to the image
  69469. */
  69470. export class FilterPostProcess extends PostProcess {
  69471. /** The matrix to be applied to the image */
  69472. kernelMatrix: Matrix;
  69473. /**
  69474. * Gets a string identifying the name of the class
  69475. * @returns "FilterPostProcess" string
  69476. */
  69477. getClassName(): string;
  69478. /**
  69479. *
  69480. * @param name The name of the effect.
  69481. * @param kernelMatrix The matrix to be applied to the image
  69482. * @param options The required width/height ratio to downsize to before computing the render pass.
  69483. * @param camera The camera to apply the render pass to.
  69484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69485. * @param engine The engine which the post process will be applied. (default: current engine)
  69486. * @param reusable If the post process can be reused on the same frame. (default: false)
  69487. */
  69488. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69489. /** @hidden */
  69490. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69491. }
  69492. }
  69493. declare module BABYLON {
  69494. /** @hidden */
  69495. export var fxaaPixelShader: {
  69496. name: string;
  69497. shader: string;
  69498. };
  69499. }
  69500. declare module BABYLON {
  69501. /** @hidden */
  69502. export var fxaaVertexShader: {
  69503. name: string;
  69504. shader: string;
  69505. };
  69506. }
  69507. declare module BABYLON {
  69508. /**
  69509. * Fxaa post process
  69510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69511. */
  69512. export class FxaaPostProcess extends PostProcess {
  69513. /**
  69514. * Gets a string identifying the name of the class
  69515. * @returns "FxaaPostProcess" string
  69516. */
  69517. getClassName(): string;
  69518. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69519. private _getDefines;
  69520. /** @hidden */
  69521. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69522. }
  69523. }
  69524. declare module BABYLON {
  69525. /** @hidden */
  69526. export var grainPixelShader: {
  69527. name: string;
  69528. shader: string;
  69529. };
  69530. }
  69531. declare module BABYLON {
  69532. /**
  69533. * The GrainPostProcess adds noise to the image at mid luminance levels
  69534. */
  69535. export class GrainPostProcess extends PostProcess {
  69536. /**
  69537. * The intensity of the grain added (default: 30)
  69538. */
  69539. intensity: number;
  69540. /**
  69541. * If the grain should be randomized on every frame
  69542. */
  69543. animated: boolean;
  69544. /**
  69545. * Gets a string identifying the name of the class
  69546. * @returns "GrainPostProcess" string
  69547. */
  69548. getClassName(): string;
  69549. /**
  69550. * Creates a new instance of @see GrainPostProcess
  69551. * @param name The name of the effect.
  69552. * @param options The required width/height ratio to downsize to before computing the render pass.
  69553. * @param camera The camera to apply the render pass to.
  69554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69555. * @param engine The engine which the post process will be applied. (default: current engine)
  69556. * @param reusable If the post process can be reused on the same frame. (default: false)
  69557. * @param textureType Type of textures used when performing the post process. (default: 0)
  69558. * @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)
  69559. */
  69560. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69561. /** @hidden */
  69562. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69563. }
  69564. }
  69565. declare module BABYLON {
  69566. /** @hidden */
  69567. export var highlightsPixelShader: {
  69568. name: string;
  69569. shader: string;
  69570. };
  69571. }
  69572. declare module BABYLON {
  69573. /**
  69574. * Extracts highlights from the image
  69575. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69576. */
  69577. export class HighlightsPostProcess extends PostProcess {
  69578. /**
  69579. * Gets a string identifying the name of the class
  69580. * @returns "HighlightsPostProcess" string
  69581. */
  69582. getClassName(): string;
  69583. /**
  69584. * Extracts highlights from the image
  69585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69586. * @param name The name of the effect.
  69587. * @param options The required width/height ratio to downsize to before computing the render pass.
  69588. * @param camera The camera to apply the render pass to.
  69589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69590. * @param engine The engine which the post process will be applied. (default: current engine)
  69591. * @param reusable If the post process can be reused on the same frame. (default: false)
  69592. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69593. */
  69594. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69595. }
  69596. }
  69597. declare module BABYLON {
  69598. /** @hidden */
  69599. export var mrtFragmentDeclaration: {
  69600. name: string;
  69601. shader: string;
  69602. };
  69603. }
  69604. declare module BABYLON {
  69605. /** @hidden */
  69606. export var geometryPixelShader: {
  69607. name: string;
  69608. shader: string;
  69609. };
  69610. }
  69611. declare module BABYLON {
  69612. /** @hidden */
  69613. export var geometryVertexShader: {
  69614. name: string;
  69615. shader: string;
  69616. };
  69617. }
  69618. declare module BABYLON {
  69619. /** @hidden */
  69620. interface ISavedTransformationMatrix {
  69621. world: Matrix;
  69622. viewProjection: Matrix;
  69623. }
  69624. /**
  69625. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69626. */
  69627. export class GeometryBufferRenderer {
  69628. /**
  69629. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69630. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69631. */
  69632. static readonly POSITION_TEXTURE_TYPE: number;
  69633. /**
  69634. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69635. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69636. */
  69637. static readonly VELOCITY_TEXTURE_TYPE: number;
  69638. /**
  69639. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69640. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69641. */
  69642. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69643. /**
  69644. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69645. * in order to compute objects velocities when enableVelocity is set to "true"
  69646. * @hidden
  69647. */
  69648. _previousTransformationMatrices: {
  69649. [index: number]: ISavedTransformationMatrix;
  69650. };
  69651. /**
  69652. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69653. * in order to compute objects velocities when enableVelocity is set to "true"
  69654. * @hidden
  69655. */
  69656. _previousBonesTransformationMatrices: {
  69657. [index: number]: Float32Array;
  69658. };
  69659. /**
  69660. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69661. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69662. */
  69663. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69664. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69665. renderTransparentMeshes: boolean;
  69666. private _scene;
  69667. private _resizeObserver;
  69668. private _multiRenderTarget;
  69669. private _ratio;
  69670. private _enablePosition;
  69671. private _enableVelocity;
  69672. private _enableReflectivity;
  69673. private _positionIndex;
  69674. private _velocityIndex;
  69675. private _reflectivityIndex;
  69676. protected _effect: Effect;
  69677. protected _cachedDefines: string;
  69678. /**
  69679. * Set the render list (meshes to be rendered) used in the G buffer.
  69680. */
  69681. set renderList(meshes: Mesh[]);
  69682. /**
  69683. * Gets wether or not G buffer are supported by the running hardware.
  69684. * This requires draw buffer supports
  69685. */
  69686. get isSupported(): boolean;
  69687. /**
  69688. * Returns the index of the given texture type in the G-Buffer textures array
  69689. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69690. * @returns the index of the given texture type in the G-Buffer textures array
  69691. */
  69692. getTextureIndex(textureType: number): number;
  69693. /**
  69694. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69695. */
  69696. get enablePosition(): boolean;
  69697. /**
  69698. * Sets whether or not objects positions are enabled for the G buffer.
  69699. */
  69700. set enablePosition(enable: boolean);
  69701. /**
  69702. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69703. */
  69704. get enableVelocity(): boolean;
  69705. /**
  69706. * Sets wether or not objects velocities are enabled for the G buffer.
  69707. */
  69708. set enableVelocity(enable: boolean);
  69709. /**
  69710. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69711. */
  69712. get enableReflectivity(): boolean;
  69713. /**
  69714. * Sets wether or not objects roughness are enabled for the G buffer.
  69715. */
  69716. set enableReflectivity(enable: boolean);
  69717. /**
  69718. * Gets the scene associated with the buffer.
  69719. */
  69720. get scene(): Scene;
  69721. /**
  69722. * Gets the ratio used by the buffer during its creation.
  69723. * How big is the buffer related to the main canvas.
  69724. */
  69725. get ratio(): number;
  69726. /** @hidden */
  69727. static _SceneComponentInitialization: (scene: Scene) => void;
  69728. /**
  69729. * Creates a new G Buffer for the scene
  69730. * @param scene The scene the buffer belongs to
  69731. * @param ratio How big is the buffer related to the main canvas.
  69732. */
  69733. constructor(scene: Scene, ratio?: number);
  69734. /**
  69735. * Checks wether everything is ready to render a submesh to the G buffer.
  69736. * @param subMesh the submesh to check readiness for
  69737. * @param useInstances is the mesh drawn using instance or not
  69738. * @returns true if ready otherwise false
  69739. */
  69740. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69741. /**
  69742. * Gets the current underlying G Buffer.
  69743. * @returns the buffer
  69744. */
  69745. getGBuffer(): MultiRenderTarget;
  69746. /**
  69747. * Gets the number of samples used to render the buffer (anti aliasing).
  69748. */
  69749. get samples(): number;
  69750. /**
  69751. * Sets the number of samples used to render the buffer (anti aliasing).
  69752. */
  69753. set samples(value: number);
  69754. /**
  69755. * Disposes the renderer and frees up associated resources.
  69756. */
  69757. dispose(): void;
  69758. protected _createRenderTargets(): void;
  69759. private _copyBonesTransformationMatrices;
  69760. }
  69761. }
  69762. declare module BABYLON {
  69763. interface Scene {
  69764. /** @hidden (Backing field) */
  69765. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69766. /**
  69767. * Gets or Sets the current geometry buffer associated to the scene.
  69768. */
  69769. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69770. /**
  69771. * Enables a GeometryBufferRender and associates it with the scene
  69772. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69773. * @returns the GeometryBufferRenderer
  69774. */
  69775. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69776. /**
  69777. * Disables the GeometryBufferRender associated with the scene
  69778. */
  69779. disableGeometryBufferRenderer(): void;
  69780. }
  69781. /**
  69782. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69783. * in several rendering techniques.
  69784. */
  69785. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69786. /**
  69787. * The component name helpful to identify the component in the list of scene components.
  69788. */
  69789. readonly name: string;
  69790. /**
  69791. * The scene the component belongs to.
  69792. */
  69793. scene: Scene;
  69794. /**
  69795. * Creates a new instance of the component for the given scene
  69796. * @param scene Defines the scene to register the component in
  69797. */
  69798. constructor(scene: Scene);
  69799. /**
  69800. * Registers the component in a given scene
  69801. */
  69802. register(): void;
  69803. /**
  69804. * Rebuilds the elements related to this component in case of
  69805. * context lost for instance.
  69806. */
  69807. rebuild(): void;
  69808. /**
  69809. * Disposes the component and the associated ressources
  69810. */
  69811. dispose(): void;
  69812. private _gatherRenderTargets;
  69813. }
  69814. }
  69815. declare module BABYLON {
  69816. /** @hidden */
  69817. export var motionBlurPixelShader: {
  69818. name: string;
  69819. shader: string;
  69820. };
  69821. }
  69822. declare module BABYLON {
  69823. /**
  69824. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69825. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69826. * As an example, all you have to do is to create the post-process:
  69827. * var mb = new BABYLON.MotionBlurPostProcess(
  69828. * 'mb', // The name of the effect.
  69829. * scene, // The scene containing the objects to blur according to their velocity.
  69830. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69831. * camera // The camera to apply the render pass to.
  69832. * );
  69833. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69834. */
  69835. export class MotionBlurPostProcess extends PostProcess {
  69836. /**
  69837. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69838. */
  69839. motionStrength: number;
  69840. /**
  69841. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69842. */
  69843. get motionBlurSamples(): number;
  69844. /**
  69845. * Sets the number of iterations to be used for motion blur quality
  69846. */
  69847. set motionBlurSamples(samples: number);
  69848. private _motionBlurSamples;
  69849. private _geometryBufferRenderer;
  69850. /**
  69851. * Gets a string identifying the name of the class
  69852. * @returns "MotionBlurPostProcess" string
  69853. */
  69854. getClassName(): string;
  69855. /**
  69856. * Creates a new instance MotionBlurPostProcess
  69857. * @param name The name of the effect.
  69858. * @param scene The scene containing the objects to blur according to their velocity.
  69859. * @param options The required width/height ratio to downsize to before computing the render pass.
  69860. * @param camera The camera to apply the render pass to.
  69861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69862. * @param engine The engine which the post process will be applied. (default: current engine)
  69863. * @param reusable If the post process can be reused on the same frame. (default: false)
  69864. * @param textureType Type of textures used when performing the post process. (default: 0)
  69865. * @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)
  69866. */
  69867. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69868. /**
  69869. * Excludes the given skinned mesh from computing bones velocities.
  69870. * 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.
  69871. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69872. */
  69873. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69874. /**
  69875. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69876. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69877. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69878. */
  69879. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69880. /**
  69881. * Disposes the post process.
  69882. * @param camera The camera to dispose the post process on.
  69883. */
  69884. dispose(camera?: Camera): void;
  69885. /** @hidden */
  69886. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  69887. }
  69888. }
  69889. declare module BABYLON {
  69890. /** @hidden */
  69891. export var refractionPixelShader: {
  69892. name: string;
  69893. shader: string;
  69894. };
  69895. }
  69896. declare module BABYLON {
  69897. /**
  69898. * Post process which applies a refractin texture
  69899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69900. */
  69901. export class RefractionPostProcess extends PostProcess {
  69902. private _refTexture;
  69903. private _ownRefractionTexture;
  69904. /** the base color of the refraction (used to taint the rendering) */
  69905. color: Color3;
  69906. /** simulated refraction depth */
  69907. depth: number;
  69908. /** the coefficient of the base color (0 to remove base color tainting) */
  69909. colorLevel: number;
  69910. /** Gets the url used to load the refraction texture */
  69911. refractionTextureUrl: string;
  69912. /**
  69913. * Gets or sets the refraction texture
  69914. * Please note that you are responsible for disposing the texture if you set it manually
  69915. */
  69916. get refractionTexture(): Texture;
  69917. set refractionTexture(value: Texture);
  69918. /**
  69919. * Gets a string identifying the name of the class
  69920. * @returns "RefractionPostProcess" string
  69921. */
  69922. getClassName(): string;
  69923. /**
  69924. * Initializes the RefractionPostProcess
  69925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69926. * @param name The name of the effect.
  69927. * @param refractionTextureUrl Url of the refraction texture to use
  69928. * @param color the base color of the refraction (used to taint the rendering)
  69929. * @param depth simulated refraction depth
  69930. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69931. * @param camera The camera to apply the render pass to.
  69932. * @param options The required width/height ratio to downsize to before computing the render pass.
  69933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69934. * @param engine The engine which the post process will be applied. (default: current engine)
  69935. * @param reusable If the post process can be reused on the same frame. (default: false)
  69936. */
  69937. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69938. /**
  69939. * Disposes of the post process
  69940. * @param camera Camera to dispose post process on
  69941. */
  69942. dispose(camera: Camera): void;
  69943. /** @hidden */
  69944. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  69945. }
  69946. }
  69947. declare module BABYLON {
  69948. /** @hidden */
  69949. export var sharpenPixelShader: {
  69950. name: string;
  69951. shader: string;
  69952. };
  69953. }
  69954. declare module BABYLON {
  69955. /**
  69956. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69957. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69958. */
  69959. export class SharpenPostProcess extends PostProcess {
  69960. /**
  69961. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69962. */
  69963. colorAmount: number;
  69964. /**
  69965. * How much sharpness should be applied (default: 0.3)
  69966. */
  69967. edgeAmount: number;
  69968. /**
  69969. * Gets a string identifying the name of the class
  69970. * @returns "SharpenPostProcess" string
  69971. */
  69972. getClassName(): string;
  69973. /**
  69974. * Creates a new instance ConvolutionPostProcess
  69975. * @param name The name of the effect.
  69976. * @param options The required width/height ratio to downsize to before computing the render pass.
  69977. * @param camera The camera to apply the render pass to.
  69978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69979. * @param engine The engine which the post process will be applied. (default: current engine)
  69980. * @param reusable If the post process can be reused on the same frame. (default: false)
  69981. * @param textureType Type of textures used when performing the post process. (default: 0)
  69982. * @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)
  69983. */
  69984. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69985. /** @hidden */
  69986. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  69987. }
  69988. }
  69989. declare module BABYLON {
  69990. /**
  69991. * PostProcessRenderPipeline
  69992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69993. */
  69994. export class PostProcessRenderPipeline {
  69995. private engine;
  69996. private _renderEffects;
  69997. private _renderEffectsForIsolatedPass;
  69998. /**
  69999. * List of inspectable custom properties (used by the Inspector)
  70000. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70001. */
  70002. inspectableCustomProperties: IInspectable[];
  70003. /**
  70004. * @hidden
  70005. */
  70006. protected _cameras: Camera[];
  70007. /** @hidden */
  70008. _name: string;
  70009. /**
  70010. * Gets pipeline name
  70011. */
  70012. get name(): string;
  70013. /** Gets the list of attached cameras */
  70014. get cameras(): Camera[];
  70015. /**
  70016. * Initializes a PostProcessRenderPipeline
  70017. * @param engine engine to add the pipeline to
  70018. * @param name name of the pipeline
  70019. */
  70020. constructor(engine: Engine, name: string);
  70021. /**
  70022. * Gets the class name
  70023. * @returns "PostProcessRenderPipeline"
  70024. */
  70025. getClassName(): string;
  70026. /**
  70027. * If all the render effects in the pipeline are supported
  70028. */
  70029. get isSupported(): boolean;
  70030. /**
  70031. * Adds an effect to the pipeline
  70032. * @param renderEffect the effect to add
  70033. */
  70034. addEffect(renderEffect: PostProcessRenderEffect): void;
  70035. /** @hidden */
  70036. _rebuild(): void;
  70037. /** @hidden */
  70038. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70039. /** @hidden */
  70040. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70041. /** @hidden */
  70042. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70043. /** @hidden */
  70044. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70045. /** @hidden */
  70046. _attachCameras(cameras: Camera, unique: boolean): void;
  70047. /** @hidden */
  70048. _attachCameras(cameras: Camera[], unique: boolean): void;
  70049. /** @hidden */
  70050. _detachCameras(cameras: Camera): void;
  70051. /** @hidden */
  70052. _detachCameras(cameras: Nullable<Camera[]>): void;
  70053. /** @hidden */
  70054. _update(): void;
  70055. /** @hidden */
  70056. _reset(): void;
  70057. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70058. /**
  70059. * Sets the required values to the prepass renderer.
  70060. * @param prePassRenderer defines the prepass renderer to setup.
  70061. * @returns true if the pre pass is needed.
  70062. */
  70063. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70064. /**
  70065. * Disposes of the pipeline
  70066. */
  70067. dispose(): void;
  70068. }
  70069. }
  70070. declare module BABYLON {
  70071. /**
  70072. * PostProcessRenderPipelineManager class
  70073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70074. */
  70075. export class PostProcessRenderPipelineManager {
  70076. private _renderPipelines;
  70077. /**
  70078. * Initializes a PostProcessRenderPipelineManager
  70079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70080. */
  70081. constructor();
  70082. /**
  70083. * Gets the list of supported render pipelines
  70084. */
  70085. get supportedPipelines(): PostProcessRenderPipeline[];
  70086. /**
  70087. * Adds a pipeline to the manager
  70088. * @param renderPipeline The pipeline to add
  70089. */
  70090. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70091. /**
  70092. * Attaches a camera to the pipeline
  70093. * @param renderPipelineName The name of the pipeline to attach to
  70094. * @param cameras the camera to attach
  70095. * @param unique if the camera can be attached multiple times to the pipeline
  70096. */
  70097. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70098. /**
  70099. * Detaches a camera from the pipeline
  70100. * @param renderPipelineName The name of the pipeline to detach from
  70101. * @param cameras the camera to detach
  70102. */
  70103. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70104. /**
  70105. * Enables an effect by name on a pipeline
  70106. * @param renderPipelineName the name of the pipeline to enable the effect in
  70107. * @param renderEffectName the name of the effect to enable
  70108. * @param cameras the cameras that the effect should be enabled on
  70109. */
  70110. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70111. /**
  70112. * Disables an effect by name on a pipeline
  70113. * @param renderPipelineName the name of the pipeline to disable the effect in
  70114. * @param renderEffectName the name of the effect to disable
  70115. * @param cameras the cameras that the effect should be disabled on
  70116. */
  70117. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70118. /**
  70119. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70120. */
  70121. update(): void;
  70122. /** @hidden */
  70123. _rebuild(): void;
  70124. /**
  70125. * Disposes of the manager and pipelines
  70126. */
  70127. dispose(): void;
  70128. }
  70129. }
  70130. declare module BABYLON {
  70131. interface Scene {
  70132. /** @hidden (Backing field) */
  70133. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70134. /**
  70135. * Gets the postprocess render pipeline manager
  70136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70137. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70138. */
  70139. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70140. }
  70141. /**
  70142. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70143. */
  70144. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70145. /**
  70146. * The component name helpfull to identify the component in the list of scene components.
  70147. */
  70148. readonly name: string;
  70149. /**
  70150. * The scene the component belongs to.
  70151. */
  70152. scene: Scene;
  70153. /**
  70154. * Creates a new instance of the component for the given scene
  70155. * @param scene Defines the scene to register the component in
  70156. */
  70157. constructor(scene: Scene);
  70158. /**
  70159. * Registers the component in a given scene
  70160. */
  70161. register(): void;
  70162. /**
  70163. * Rebuilds the elements related to this component in case of
  70164. * context lost for instance.
  70165. */
  70166. rebuild(): void;
  70167. /**
  70168. * Disposes the component and the associated ressources
  70169. */
  70170. dispose(): void;
  70171. private _gatherRenderTargets;
  70172. }
  70173. }
  70174. declare module BABYLON {
  70175. /**
  70176. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70177. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70178. */
  70179. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70180. private _scene;
  70181. private _camerasToBeAttached;
  70182. /**
  70183. * ID of the sharpen post process,
  70184. */
  70185. private readonly SharpenPostProcessId;
  70186. /**
  70187. * @ignore
  70188. * ID of the image processing post process;
  70189. */
  70190. readonly ImageProcessingPostProcessId: string;
  70191. /**
  70192. * @ignore
  70193. * ID of the Fast Approximate Anti-Aliasing post process;
  70194. */
  70195. readonly FxaaPostProcessId: string;
  70196. /**
  70197. * ID of the chromatic aberration post process,
  70198. */
  70199. private readonly ChromaticAberrationPostProcessId;
  70200. /**
  70201. * ID of the grain post process
  70202. */
  70203. private readonly GrainPostProcessId;
  70204. /**
  70205. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70206. */
  70207. sharpen: SharpenPostProcess;
  70208. private _sharpenEffect;
  70209. private bloom;
  70210. /**
  70211. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70212. */
  70213. depthOfField: DepthOfFieldEffect;
  70214. /**
  70215. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70216. */
  70217. fxaa: FxaaPostProcess;
  70218. /**
  70219. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70220. */
  70221. imageProcessing: ImageProcessingPostProcess;
  70222. /**
  70223. * Chromatic aberration post process which will shift rgb colors in the image
  70224. */
  70225. chromaticAberration: ChromaticAberrationPostProcess;
  70226. private _chromaticAberrationEffect;
  70227. /**
  70228. * Grain post process which add noise to the image
  70229. */
  70230. grain: GrainPostProcess;
  70231. private _grainEffect;
  70232. /**
  70233. * Glow post process which adds a glow to emissive areas of the image
  70234. */
  70235. private _glowLayer;
  70236. /**
  70237. * Animations which can be used to tweak settings over a period of time
  70238. */
  70239. animations: Animation[];
  70240. private _imageProcessingConfigurationObserver;
  70241. private _sharpenEnabled;
  70242. private _bloomEnabled;
  70243. private _depthOfFieldEnabled;
  70244. private _depthOfFieldBlurLevel;
  70245. private _fxaaEnabled;
  70246. private _imageProcessingEnabled;
  70247. private _defaultPipelineTextureType;
  70248. private _bloomScale;
  70249. private _chromaticAberrationEnabled;
  70250. private _grainEnabled;
  70251. private _buildAllowed;
  70252. /**
  70253. * Gets active scene
  70254. */
  70255. get scene(): Scene;
  70256. /**
  70257. * Enable or disable the sharpen process from the pipeline
  70258. */
  70259. set sharpenEnabled(enabled: boolean);
  70260. get sharpenEnabled(): boolean;
  70261. private _resizeObserver;
  70262. private _hardwareScaleLevel;
  70263. private _bloomKernel;
  70264. /**
  70265. * Specifies the size of the bloom blur kernel, relative to the final output size
  70266. */
  70267. get bloomKernel(): number;
  70268. set bloomKernel(value: number);
  70269. /**
  70270. * Specifies the weight of the bloom in the final rendering
  70271. */
  70272. private _bloomWeight;
  70273. /**
  70274. * Specifies the luma threshold for the area that will be blurred by the bloom
  70275. */
  70276. private _bloomThreshold;
  70277. private _hdr;
  70278. /**
  70279. * The strength of the bloom.
  70280. */
  70281. set bloomWeight(value: number);
  70282. get bloomWeight(): number;
  70283. /**
  70284. * The strength of the bloom.
  70285. */
  70286. set bloomThreshold(value: number);
  70287. get bloomThreshold(): number;
  70288. /**
  70289. * The scale of the bloom, lower value will provide better performance.
  70290. */
  70291. set bloomScale(value: number);
  70292. get bloomScale(): number;
  70293. /**
  70294. * Enable or disable the bloom from the pipeline
  70295. */
  70296. set bloomEnabled(enabled: boolean);
  70297. get bloomEnabled(): boolean;
  70298. private _rebuildBloom;
  70299. /**
  70300. * If the depth of field is enabled.
  70301. */
  70302. get depthOfFieldEnabled(): boolean;
  70303. set depthOfFieldEnabled(enabled: boolean);
  70304. /**
  70305. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70306. */
  70307. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70308. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70309. /**
  70310. * If the anti aliasing is enabled.
  70311. */
  70312. set fxaaEnabled(enabled: boolean);
  70313. get fxaaEnabled(): boolean;
  70314. private _samples;
  70315. /**
  70316. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70317. */
  70318. set samples(sampleCount: number);
  70319. get samples(): number;
  70320. /**
  70321. * If image processing is enabled.
  70322. */
  70323. set imageProcessingEnabled(enabled: boolean);
  70324. get imageProcessingEnabled(): boolean;
  70325. /**
  70326. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70327. */
  70328. set glowLayerEnabled(enabled: boolean);
  70329. get glowLayerEnabled(): boolean;
  70330. /**
  70331. * Gets the glow layer (or null if not defined)
  70332. */
  70333. get glowLayer(): Nullable<GlowLayer>;
  70334. /**
  70335. * Enable or disable the chromaticAberration process from the pipeline
  70336. */
  70337. set chromaticAberrationEnabled(enabled: boolean);
  70338. get chromaticAberrationEnabled(): boolean;
  70339. /**
  70340. * Enable or disable the grain process from the pipeline
  70341. */
  70342. set grainEnabled(enabled: boolean);
  70343. get grainEnabled(): boolean;
  70344. /**
  70345. * @constructor
  70346. * @param name - The rendering pipeline name (default: "")
  70347. * @param hdr - If high dynamic range textures should be used (default: true)
  70348. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70349. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70350. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70351. */
  70352. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70353. /**
  70354. * Get the class name
  70355. * @returns "DefaultRenderingPipeline"
  70356. */
  70357. getClassName(): string;
  70358. /**
  70359. * Force the compilation of the entire pipeline.
  70360. */
  70361. prepare(): void;
  70362. private _hasCleared;
  70363. private _prevPostProcess;
  70364. private _prevPrevPostProcess;
  70365. private _setAutoClearAndTextureSharing;
  70366. private _depthOfFieldSceneObserver;
  70367. private _buildPipeline;
  70368. private _disposePostProcesses;
  70369. /**
  70370. * Adds a camera to the pipeline
  70371. * @param camera the camera to be added
  70372. */
  70373. addCamera(camera: Camera): void;
  70374. /**
  70375. * Removes a camera from the pipeline
  70376. * @param camera the camera to remove
  70377. */
  70378. removeCamera(camera: Camera): void;
  70379. /**
  70380. * Dispose of the pipeline and stop all post processes
  70381. */
  70382. dispose(): void;
  70383. /**
  70384. * Serialize the rendering pipeline (Used when exporting)
  70385. * @returns the serialized object
  70386. */
  70387. serialize(): any;
  70388. /**
  70389. * Parse the serialized pipeline
  70390. * @param source Source pipeline.
  70391. * @param scene The scene to load the pipeline to.
  70392. * @param rootUrl The URL of the serialized pipeline.
  70393. * @returns An instantiated pipeline from the serialized object.
  70394. */
  70395. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70396. }
  70397. }
  70398. declare module BABYLON {
  70399. /** @hidden */
  70400. export var lensHighlightsPixelShader: {
  70401. name: string;
  70402. shader: string;
  70403. };
  70404. }
  70405. declare module BABYLON {
  70406. /** @hidden */
  70407. export var depthOfFieldPixelShader: {
  70408. name: string;
  70409. shader: string;
  70410. };
  70411. }
  70412. declare module BABYLON {
  70413. /**
  70414. * BABYLON.JS Chromatic Aberration GLSL Shader
  70415. * Author: Olivier Guyot
  70416. * Separates very slightly R, G and B colors on the edges of the screen
  70417. * Inspired by Francois Tarlier & Martins Upitis
  70418. */
  70419. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70420. /**
  70421. * @ignore
  70422. * The chromatic aberration PostProcess id in the pipeline
  70423. */
  70424. LensChromaticAberrationEffect: string;
  70425. /**
  70426. * @ignore
  70427. * The highlights enhancing PostProcess id in the pipeline
  70428. */
  70429. HighlightsEnhancingEffect: string;
  70430. /**
  70431. * @ignore
  70432. * The depth-of-field PostProcess id in the pipeline
  70433. */
  70434. LensDepthOfFieldEffect: string;
  70435. private _scene;
  70436. private _depthTexture;
  70437. private _grainTexture;
  70438. private _chromaticAberrationPostProcess;
  70439. private _highlightsPostProcess;
  70440. private _depthOfFieldPostProcess;
  70441. private _edgeBlur;
  70442. private _grainAmount;
  70443. private _chromaticAberration;
  70444. private _distortion;
  70445. private _highlightsGain;
  70446. private _highlightsThreshold;
  70447. private _dofDistance;
  70448. private _dofAperture;
  70449. private _dofDarken;
  70450. private _dofPentagon;
  70451. private _blurNoise;
  70452. /**
  70453. * @constructor
  70454. *
  70455. * Effect parameters are as follow:
  70456. * {
  70457. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70458. * edge_blur: number; // from 0 to x (1 for realism)
  70459. * distortion: number; // from 0 to x (1 for realism)
  70460. * grain_amount: number; // from 0 to 1
  70461. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70462. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70463. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70464. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70465. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70466. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70467. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70468. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70469. * }
  70470. * Note: if an effect parameter is unset, effect is disabled
  70471. *
  70472. * @param name The rendering pipeline name
  70473. * @param parameters - An object containing all parameters (see above)
  70474. * @param scene The scene linked to this pipeline
  70475. * @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)
  70476. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70477. */
  70478. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70479. /**
  70480. * Get the class name
  70481. * @returns "LensRenderingPipeline"
  70482. */
  70483. getClassName(): string;
  70484. /**
  70485. * Gets associated scene
  70486. */
  70487. get scene(): Scene;
  70488. /**
  70489. * Gets or sets the edge blur
  70490. */
  70491. get edgeBlur(): number;
  70492. set edgeBlur(value: number);
  70493. /**
  70494. * Gets or sets the grain amount
  70495. */
  70496. get grainAmount(): number;
  70497. set grainAmount(value: number);
  70498. /**
  70499. * Gets or sets the chromatic aberration amount
  70500. */
  70501. get chromaticAberration(): number;
  70502. set chromaticAberration(value: number);
  70503. /**
  70504. * Gets or sets the depth of field aperture
  70505. */
  70506. get dofAperture(): number;
  70507. set dofAperture(value: number);
  70508. /**
  70509. * Gets or sets the edge distortion
  70510. */
  70511. get edgeDistortion(): number;
  70512. set edgeDistortion(value: number);
  70513. /**
  70514. * Gets or sets the depth of field distortion
  70515. */
  70516. get dofDistortion(): number;
  70517. set dofDistortion(value: number);
  70518. /**
  70519. * Gets or sets the darken out of focus amount
  70520. */
  70521. get darkenOutOfFocus(): number;
  70522. set darkenOutOfFocus(value: number);
  70523. /**
  70524. * Gets or sets a boolean indicating if blur noise is enabled
  70525. */
  70526. get blurNoise(): boolean;
  70527. set blurNoise(value: boolean);
  70528. /**
  70529. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70530. */
  70531. get pentagonBokeh(): boolean;
  70532. set pentagonBokeh(value: boolean);
  70533. /**
  70534. * Gets or sets the highlight grain amount
  70535. */
  70536. get highlightsGain(): number;
  70537. set highlightsGain(value: number);
  70538. /**
  70539. * Gets or sets the highlight threshold
  70540. */
  70541. get highlightsThreshold(): number;
  70542. set highlightsThreshold(value: number);
  70543. /**
  70544. * Sets the amount of blur at the edges
  70545. * @param amount blur amount
  70546. */
  70547. setEdgeBlur(amount: number): void;
  70548. /**
  70549. * Sets edge blur to 0
  70550. */
  70551. disableEdgeBlur(): void;
  70552. /**
  70553. * Sets the amout of grain
  70554. * @param amount Amount of grain
  70555. */
  70556. setGrainAmount(amount: number): void;
  70557. /**
  70558. * Set grain amount to 0
  70559. */
  70560. disableGrain(): void;
  70561. /**
  70562. * Sets the chromatic aberration amount
  70563. * @param amount amount of chromatic aberration
  70564. */
  70565. setChromaticAberration(amount: number): void;
  70566. /**
  70567. * Sets chromatic aberration amount to 0
  70568. */
  70569. disableChromaticAberration(): void;
  70570. /**
  70571. * Sets the EdgeDistortion amount
  70572. * @param amount amount of EdgeDistortion
  70573. */
  70574. setEdgeDistortion(amount: number): void;
  70575. /**
  70576. * Sets edge distortion to 0
  70577. */
  70578. disableEdgeDistortion(): void;
  70579. /**
  70580. * Sets the FocusDistance amount
  70581. * @param amount amount of FocusDistance
  70582. */
  70583. setFocusDistance(amount: number): void;
  70584. /**
  70585. * Disables depth of field
  70586. */
  70587. disableDepthOfField(): void;
  70588. /**
  70589. * Sets the Aperture amount
  70590. * @param amount amount of Aperture
  70591. */
  70592. setAperture(amount: number): void;
  70593. /**
  70594. * Sets the DarkenOutOfFocus amount
  70595. * @param amount amount of DarkenOutOfFocus
  70596. */
  70597. setDarkenOutOfFocus(amount: number): void;
  70598. private _pentagonBokehIsEnabled;
  70599. /**
  70600. * Creates a pentagon bokeh effect
  70601. */
  70602. enablePentagonBokeh(): void;
  70603. /**
  70604. * Disables the pentagon bokeh effect
  70605. */
  70606. disablePentagonBokeh(): void;
  70607. /**
  70608. * Enables noise blur
  70609. */
  70610. enableNoiseBlur(): void;
  70611. /**
  70612. * Disables noise blur
  70613. */
  70614. disableNoiseBlur(): void;
  70615. /**
  70616. * Sets the HighlightsGain amount
  70617. * @param amount amount of HighlightsGain
  70618. */
  70619. setHighlightsGain(amount: number): void;
  70620. /**
  70621. * Sets the HighlightsThreshold amount
  70622. * @param amount amount of HighlightsThreshold
  70623. */
  70624. setHighlightsThreshold(amount: number): void;
  70625. /**
  70626. * Disables highlights
  70627. */
  70628. disableHighlights(): void;
  70629. /**
  70630. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70631. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70632. */
  70633. dispose(disableDepthRender?: boolean): void;
  70634. private _createChromaticAberrationPostProcess;
  70635. private _createHighlightsPostProcess;
  70636. private _createDepthOfFieldPostProcess;
  70637. private _createGrainTexture;
  70638. }
  70639. }
  70640. declare module BABYLON {
  70641. /** @hidden */
  70642. export var ssao2PixelShader: {
  70643. name: string;
  70644. shader: string;
  70645. };
  70646. }
  70647. declare module BABYLON {
  70648. /** @hidden */
  70649. export var ssaoCombinePixelShader: {
  70650. name: string;
  70651. shader: string;
  70652. };
  70653. }
  70654. declare module BABYLON {
  70655. /**
  70656. * Render pipeline to produce ssao effect
  70657. */
  70658. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70659. /**
  70660. * @ignore
  70661. * The PassPostProcess id in the pipeline that contains the original scene color
  70662. */
  70663. SSAOOriginalSceneColorEffect: string;
  70664. /**
  70665. * @ignore
  70666. * The SSAO PostProcess id in the pipeline
  70667. */
  70668. SSAORenderEffect: string;
  70669. /**
  70670. * @ignore
  70671. * The horizontal blur PostProcess id in the pipeline
  70672. */
  70673. SSAOBlurHRenderEffect: string;
  70674. /**
  70675. * @ignore
  70676. * The vertical blur PostProcess id in the pipeline
  70677. */
  70678. SSAOBlurVRenderEffect: string;
  70679. /**
  70680. * @ignore
  70681. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70682. */
  70683. SSAOCombineRenderEffect: string;
  70684. /**
  70685. * The output strength of the SSAO post-process. Default value is 1.0.
  70686. */
  70687. totalStrength: number;
  70688. /**
  70689. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70690. */
  70691. maxZ: number;
  70692. /**
  70693. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70694. */
  70695. minZAspect: number;
  70696. private _samples;
  70697. /**
  70698. * Number of samples used for the SSAO calculations. Default value is 8
  70699. */
  70700. set samples(n: number);
  70701. get samples(): number;
  70702. private _textureSamples;
  70703. /**
  70704. * Number of samples to use for antialiasing
  70705. */
  70706. set textureSamples(n: number);
  70707. get textureSamples(): number;
  70708. /**
  70709. * Force rendering the geometry through geometry buffer
  70710. */
  70711. private _forceGeometryBuffer;
  70712. /**
  70713. * Ratio object used for SSAO ratio and blur ratio
  70714. */
  70715. private _ratio;
  70716. /**
  70717. * Dynamically generated sphere sampler.
  70718. */
  70719. private _sampleSphere;
  70720. /**
  70721. * Blur filter offsets
  70722. */
  70723. private _samplerOffsets;
  70724. private _expensiveBlur;
  70725. /**
  70726. * If bilateral blur should be used
  70727. */
  70728. set expensiveBlur(b: boolean);
  70729. get expensiveBlur(): boolean;
  70730. /**
  70731. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70732. */
  70733. radius: number;
  70734. /**
  70735. * The base color of the SSAO post-process
  70736. * The final result is "base + ssao" between [0, 1]
  70737. */
  70738. base: number;
  70739. /**
  70740. * Support test.
  70741. */
  70742. static get IsSupported(): boolean;
  70743. private _scene;
  70744. private _randomTexture;
  70745. private _originalColorPostProcess;
  70746. private _ssaoPostProcess;
  70747. private _blurHPostProcess;
  70748. private _blurVPostProcess;
  70749. private _ssaoCombinePostProcess;
  70750. private _prePassRenderer;
  70751. /**
  70752. * Gets active scene
  70753. */
  70754. get scene(): Scene;
  70755. /**
  70756. * @constructor
  70757. * @param name The rendering pipeline name
  70758. * @param scene The scene linked to this pipeline
  70759. * @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 }
  70760. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70761. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70762. */
  70763. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70764. /**
  70765. * Get the class name
  70766. * @returns "SSAO2RenderingPipeline"
  70767. */
  70768. getClassName(): string;
  70769. /**
  70770. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70771. */
  70772. dispose(disableGeometryBufferRenderer?: boolean): void;
  70773. private _createBlurPostProcess;
  70774. /** @hidden */
  70775. _rebuild(): void;
  70776. private _bits;
  70777. private _radicalInverse_VdC;
  70778. private _hammersley;
  70779. private _hemisphereSample_uniform;
  70780. private _generateHemisphere;
  70781. private _getDefinesForSSAO;
  70782. private _createSSAOPostProcess;
  70783. private _createSSAOCombinePostProcess;
  70784. private _createRandomTexture;
  70785. /**
  70786. * Serialize the rendering pipeline (Used when exporting)
  70787. * @returns the serialized object
  70788. */
  70789. serialize(): any;
  70790. /**
  70791. * Parse the serialized pipeline
  70792. * @param source Source pipeline.
  70793. * @param scene The scene to load the pipeline to.
  70794. * @param rootUrl The URL of the serialized pipeline.
  70795. * @returns An instantiated pipeline from the serialized object.
  70796. */
  70797. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70798. /**
  70799. * Sets the required values to the prepass renderer.
  70800. * @param prePassRenderer defines the prepass renderer to setup
  70801. * @returns true if the pre pass is needed.
  70802. */
  70803. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70804. }
  70805. }
  70806. declare module BABYLON {
  70807. /** @hidden */
  70808. export var ssaoPixelShader: {
  70809. name: string;
  70810. shader: string;
  70811. };
  70812. }
  70813. declare module BABYLON {
  70814. /**
  70815. * Render pipeline to produce ssao effect
  70816. */
  70817. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70818. /**
  70819. * @ignore
  70820. * The PassPostProcess id in the pipeline that contains the original scene color
  70821. */
  70822. SSAOOriginalSceneColorEffect: string;
  70823. /**
  70824. * @ignore
  70825. * The SSAO PostProcess id in the pipeline
  70826. */
  70827. SSAORenderEffect: string;
  70828. /**
  70829. * @ignore
  70830. * The horizontal blur PostProcess id in the pipeline
  70831. */
  70832. SSAOBlurHRenderEffect: string;
  70833. /**
  70834. * @ignore
  70835. * The vertical blur PostProcess id in the pipeline
  70836. */
  70837. SSAOBlurVRenderEffect: string;
  70838. /**
  70839. * @ignore
  70840. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70841. */
  70842. SSAOCombineRenderEffect: string;
  70843. /**
  70844. * The output strength of the SSAO post-process. Default value is 1.0.
  70845. */
  70846. totalStrength: number;
  70847. /**
  70848. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70849. */
  70850. radius: number;
  70851. /**
  70852. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70853. * Must not be equal to fallOff and superior to fallOff.
  70854. * Default value is 0.0075
  70855. */
  70856. area: number;
  70857. /**
  70858. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70859. * Must not be equal to area and inferior to area.
  70860. * Default value is 0.000001
  70861. */
  70862. fallOff: number;
  70863. /**
  70864. * The base color of the SSAO post-process
  70865. * The final result is "base + ssao" between [0, 1]
  70866. */
  70867. base: number;
  70868. private _scene;
  70869. private _depthTexture;
  70870. private _randomTexture;
  70871. private _originalColorPostProcess;
  70872. private _ssaoPostProcess;
  70873. private _blurHPostProcess;
  70874. private _blurVPostProcess;
  70875. private _ssaoCombinePostProcess;
  70876. private _firstUpdate;
  70877. /**
  70878. * Gets active scene
  70879. */
  70880. get scene(): Scene;
  70881. /**
  70882. * @constructor
  70883. * @param name - The rendering pipeline name
  70884. * @param scene - The scene linked to this pipeline
  70885. * @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 }
  70886. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70887. */
  70888. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70889. /**
  70890. * Get the class name
  70891. * @returns "SSAORenderingPipeline"
  70892. */
  70893. getClassName(): string;
  70894. /**
  70895. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70896. */
  70897. dispose(disableDepthRender?: boolean): void;
  70898. private _createBlurPostProcess;
  70899. /** @hidden */
  70900. _rebuild(): void;
  70901. private _createSSAOPostProcess;
  70902. private _createSSAOCombinePostProcess;
  70903. private _createRandomTexture;
  70904. }
  70905. }
  70906. declare module BABYLON {
  70907. /** @hidden */
  70908. export var screenSpaceReflectionPixelShader: {
  70909. name: string;
  70910. shader: string;
  70911. };
  70912. }
  70913. declare module BABYLON {
  70914. /**
  70915. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70916. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70917. */
  70918. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70919. /**
  70920. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70921. */
  70922. threshold: number;
  70923. /**
  70924. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70925. */
  70926. strength: number;
  70927. /**
  70928. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70929. */
  70930. reflectionSpecularFalloffExponent: number;
  70931. /**
  70932. * 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]
  70933. */
  70934. step: number;
  70935. /**
  70936. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70937. */
  70938. roughnessFactor: number;
  70939. private _geometryBufferRenderer;
  70940. private _enableSmoothReflections;
  70941. private _reflectionSamples;
  70942. private _smoothSteps;
  70943. /**
  70944. * Gets a string identifying the name of the class
  70945. * @returns "ScreenSpaceReflectionPostProcess" string
  70946. */
  70947. getClassName(): string;
  70948. /**
  70949. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70950. * @param name The name of the effect.
  70951. * @param scene The scene containing the objects to calculate reflections.
  70952. * @param options The required width/height ratio to downsize to before computing the render pass.
  70953. * @param camera The camera to apply the render pass to.
  70954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70955. * @param engine The engine which the post process will be applied. (default: current engine)
  70956. * @param reusable If the post process can be reused on the same frame. (default: false)
  70957. * @param textureType Type of textures used when performing the post process. (default: 0)
  70958. * @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)
  70959. */
  70960. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70961. /**
  70962. * Gets wether or not smoothing reflections is enabled.
  70963. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70964. */
  70965. get enableSmoothReflections(): boolean;
  70966. /**
  70967. * Sets wether or not smoothing reflections is enabled.
  70968. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70969. */
  70970. set enableSmoothReflections(enabled: boolean);
  70971. /**
  70972. * Gets the number of samples taken while computing reflections. More samples count is high,
  70973. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70974. */
  70975. get reflectionSamples(): number;
  70976. /**
  70977. * Sets the number of samples taken while computing reflections. More samples count is high,
  70978. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70979. */
  70980. set reflectionSamples(samples: number);
  70981. /**
  70982. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70983. * more the post-process will require GPU power and can generate a drop in FPS.
  70984. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70985. */
  70986. get smoothSteps(): number;
  70987. set smoothSteps(steps: number);
  70988. private _updateEffectDefines;
  70989. /** @hidden */
  70990. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  70991. }
  70992. }
  70993. declare module BABYLON {
  70994. /** @hidden */
  70995. export var standardPixelShader: {
  70996. name: string;
  70997. shader: string;
  70998. };
  70999. }
  71000. declare module BABYLON {
  71001. /**
  71002. * Standard rendering pipeline
  71003. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71004. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71005. */
  71006. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71007. /**
  71008. * Public members
  71009. */
  71010. /**
  71011. * Post-process which contains the original scene color before the pipeline applies all the effects
  71012. */
  71013. originalPostProcess: Nullable<PostProcess>;
  71014. /**
  71015. * Post-process used to down scale an image x4
  71016. */
  71017. downSampleX4PostProcess: Nullable<PostProcess>;
  71018. /**
  71019. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71020. */
  71021. brightPassPostProcess: Nullable<PostProcess>;
  71022. /**
  71023. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71024. */
  71025. blurHPostProcesses: PostProcess[];
  71026. /**
  71027. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71028. */
  71029. blurVPostProcesses: PostProcess[];
  71030. /**
  71031. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71032. */
  71033. textureAdderPostProcess: Nullable<PostProcess>;
  71034. /**
  71035. * Post-process used to create volumetric lighting effect
  71036. */
  71037. volumetricLightPostProcess: Nullable<PostProcess>;
  71038. /**
  71039. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71040. */
  71041. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71042. /**
  71043. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71044. */
  71045. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71046. /**
  71047. * Post-process used to merge the volumetric light effect and the real scene color
  71048. */
  71049. volumetricLightMergePostProces: Nullable<PostProcess>;
  71050. /**
  71051. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71052. */
  71053. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71054. /**
  71055. * Base post-process used to calculate the average luminance of the final image for HDR
  71056. */
  71057. luminancePostProcess: Nullable<PostProcess>;
  71058. /**
  71059. * Post-processes used to create down sample post-processes in order to get
  71060. * the average luminance of the final image for HDR
  71061. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71062. */
  71063. luminanceDownSamplePostProcesses: PostProcess[];
  71064. /**
  71065. * Post-process used to create a HDR effect (light adaptation)
  71066. */
  71067. hdrPostProcess: Nullable<PostProcess>;
  71068. /**
  71069. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71070. */
  71071. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71072. /**
  71073. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71074. */
  71075. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71076. /**
  71077. * Post-process used to merge the final HDR post-process and the real scene color
  71078. */
  71079. hdrFinalPostProcess: Nullable<PostProcess>;
  71080. /**
  71081. * Post-process used to create a lens flare effect
  71082. */
  71083. lensFlarePostProcess: Nullable<PostProcess>;
  71084. /**
  71085. * Post-process that merges the result of the lens flare post-process and the real scene color
  71086. */
  71087. lensFlareComposePostProcess: Nullable<PostProcess>;
  71088. /**
  71089. * Post-process used to create a motion blur effect
  71090. */
  71091. motionBlurPostProcess: Nullable<PostProcess>;
  71092. /**
  71093. * Post-process used to create a depth of field effect
  71094. */
  71095. depthOfFieldPostProcess: Nullable<PostProcess>;
  71096. /**
  71097. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71098. */
  71099. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71100. /**
  71101. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71102. */
  71103. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71104. /**
  71105. * Represents the brightness threshold in order to configure the illuminated surfaces
  71106. */
  71107. brightThreshold: number;
  71108. /**
  71109. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71110. */
  71111. blurWidth: number;
  71112. /**
  71113. * Sets if the blur for highlighted surfaces must be only horizontal
  71114. */
  71115. horizontalBlur: boolean;
  71116. /**
  71117. * Gets the overall exposure used by the pipeline
  71118. */
  71119. get exposure(): number;
  71120. /**
  71121. * Sets the overall exposure used by the pipeline
  71122. */
  71123. set exposure(value: number);
  71124. /**
  71125. * Texture used typically to simulate "dirty" on camera lens
  71126. */
  71127. lensTexture: Nullable<Texture>;
  71128. /**
  71129. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71130. */
  71131. volumetricLightCoefficient: number;
  71132. /**
  71133. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71134. */
  71135. volumetricLightPower: number;
  71136. /**
  71137. * Used the set the blur intensity to smooth the volumetric lights
  71138. */
  71139. volumetricLightBlurScale: number;
  71140. /**
  71141. * Light (spot or directional) used to generate the volumetric lights rays
  71142. * The source light must have a shadow generate so the pipeline can get its
  71143. * depth map
  71144. */
  71145. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71146. /**
  71147. * For eye adaptation, represents the minimum luminance the eye can see
  71148. */
  71149. hdrMinimumLuminance: number;
  71150. /**
  71151. * For eye adaptation, represents the decrease luminance speed
  71152. */
  71153. hdrDecreaseRate: number;
  71154. /**
  71155. * For eye adaptation, represents the increase luminance speed
  71156. */
  71157. hdrIncreaseRate: number;
  71158. /**
  71159. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71160. */
  71161. get hdrAutoExposure(): boolean;
  71162. /**
  71163. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71164. */
  71165. set hdrAutoExposure(value: boolean);
  71166. /**
  71167. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71168. */
  71169. lensColorTexture: Nullable<Texture>;
  71170. /**
  71171. * The overall strengh for the lens flare effect
  71172. */
  71173. lensFlareStrength: number;
  71174. /**
  71175. * Dispersion coefficient for lens flare ghosts
  71176. */
  71177. lensFlareGhostDispersal: number;
  71178. /**
  71179. * Main lens flare halo width
  71180. */
  71181. lensFlareHaloWidth: number;
  71182. /**
  71183. * Based on the lens distortion effect, defines how much the lens flare result
  71184. * is distorted
  71185. */
  71186. lensFlareDistortionStrength: number;
  71187. /**
  71188. * Configures the blur intensity used for for lens flare (halo)
  71189. */
  71190. lensFlareBlurWidth: number;
  71191. /**
  71192. * Lens star texture must be used to simulate rays on the flares and is available
  71193. * in the documentation
  71194. */
  71195. lensStarTexture: Nullable<Texture>;
  71196. /**
  71197. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71198. * flare effect by taking account of the dirt texture
  71199. */
  71200. lensFlareDirtTexture: Nullable<Texture>;
  71201. /**
  71202. * Represents the focal length for the depth of field effect
  71203. */
  71204. depthOfFieldDistance: number;
  71205. /**
  71206. * Represents the blur intensity for the blurred part of the depth of field effect
  71207. */
  71208. depthOfFieldBlurWidth: number;
  71209. /**
  71210. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71211. */
  71212. get motionStrength(): number;
  71213. /**
  71214. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71215. */
  71216. set motionStrength(strength: number);
  71217. /**
  71218. * Gets wether or not the motion blur post-process is object based or screen based.
  71219. */
  71220. get objectBasedMotionBlur(): boolean;
  71221. /**
  71222. * Sets wether or not the motion blur post-process should be object based or screen based
  71223. */
  71224. set objectBasedMotionBlur(value: boolean);
  71225. /**
  71226. * List of animations for the pipeline (IAnimatable implementation)
  71227. */
  71228. animations: Animation[];
  71229. /**
  71230. * Private members
  71231. */
  71232. private _scene;
  71233. private _currentDepthOfFieldSource;
  71234. private _basePostProcess;
  71235. private _fixedExposure;
  71236. private _currentExposure;
  71237. private _hdrAutoExposure;
  71238. private _hdrCurrentLuminance;
  71239. private _motionStrength;
  71240. private _isObjectBasedMotionBlur;
  71241. private _floatTextureType;
  71242. private _camerasToBeAttached;
  71243. private _ratio;
  71244. private _bloomEnabled;
  71245. private _depthOfFieldEnabled;
  71246. private _vlsEnabled;
  71247. private _lensFlareEnabled;
  71248. private _hdrEnabled;
  71249. private _motionBlurEnabled;
  71250. private _fxaaEnabled;
  71251. private _screenSpaceReflectionsEnabled;
  71252. private _motionBlurSamples;
  71253. private _volumetricLightStepsCount;
  71254. private _samples;
  71255. /**
  71256. * @ignore
  71257. * Specifies if the bloom pipeline is enabled
  71258. */
  71259. get BloomEnabled(): boolean;
  71260. set BloomEnabled(enabled: boolean);
  71261. /**
  71262. * @ignore
  71263. * Specifies if the depth of field pipeline is enabed
  71264. */
  71265. get DepthOfFieldEnabled(): boolean;
  71266. set DepthOfFieldEnabled(enabled: boolean);
  71267. /**
  71268. * @ignore
  71269. * Specifies if the lens flare pipeline is enabed
  71270. */
  71271. get LensFlareEnabled(): boolean;
  71272. set LensFlareEnabled(enabled: boolean);
  71273. /**
  71274. * @ignore
  71275. * Specifies if the HDR pipeline is enabled
  71276. */
  71277. get HDREnabled(): boolean;
  71278. set HDREnabled(enabled: boolean);
  71279. /**
  71280. * @ignore
  71281. * Specifies if the volumetric lights scattering effect is enabled
  71282. */
  71283. get VLSEnabled(): boolean;
  71284. set VLSEnabled(enabled: boolean);
  71285. /**
  71286. * @ignore
  71287. * Specifies if the motion blur effect is enabled
  71288. */
  71289. get MotionBlurEnabled(): boolean;
  71290. set MotionBlurEnabled(enabled: boolean);
  71291. /**
  71292. * Specifies if anti-aliasing is enabled
  71293. */
  71294. get fxaaEnabled(): boolean;
  71295. set fxaaEnabled(enabled: boolean);
  71296. /**
  71297. * Specifies if screen space reflections are enabled.
  71298. */
  71299. get screenSpaceReflectionsEnabled(): boolean;
  71300. set screenSpaceReflectionsEnabled(enabled: boolean);
  71301. /**
  71302. * Specifies the number of steps used to calculate the volumetric lights
  71303. * Typically in interval [50, 200]
  71304. */
  71305. get volumetricLightStepsCount(): number;
  71306. set volumetricLightStepsCount(count: number);
  71307. /**
  71308. * Specifies the number of samples used for the motion blur effect
  71309. * Typically in interval [16, 64]
  71310. */
  71311. get motionBlurSamples(): number;
  71312. set motionBlurSamples(samples: number);
  71313. /**
  71314. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71315. */
  71316. get samples(): number;
  71317. set samples(sampleCount: number);
  71318. /**
  71319. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71320. * @constructor
  71321. * @param name The rendering pipeline name
  71322. * @param scene The scene linked to this pipeline
  71323. * @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)
  71324. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71325. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71326. */
  71327. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71328. private _buildPipeline;
  71329. private _createDownSampleX4PostProcess;
  71330. private _createBrightPassPostProcess;
  71331. private _createBlurPostProcesses;
  71332. private _createTextureAdderPostProcess;
  71333. private _createVolumetricLightPostProcess;
  71334. private _createLuminancePostProcesses;
  71335. private _createHdrPostProcess;
  71336. private _createLensFlarePostProcess;
  71337. private _createDepthOfFieldPostProcess;
  71338. private _createMotionBlurPostProcess;
  71339. private _getDepthTexture;
  71340. private _disposePostProcesses;
  71341. /**
  71342. * Dispose of the pipeline and stop all post processes
  71343. */
  71344. dispose(): void;
  71345. /**
  71346. * Serialize the rendering pipeline (Used when exporting)
  71347. * @returns the serialized object
  71348. */
  71349. serialize(): any;
  71350. /**
  71351. * Parse the serialized pipeline
  71352. * @param source Source pipeline.
  71353. * @param scene The scene to load the pipeline to.
  71354. * @param rootUrl The URL of the serialized pipeline.
  71355. * @returns An instantiated pipeline from the serialized object.
  71356. */
  71357. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71358. /**
  71359. * Luminance steps
  71360. */
  71361. static LuminanceSteps: number;
  71362. }
  71363. }
  71364. declare module BABYLON {
  71365. /** @hidden */
  71366. export var stereoscopicInterlacePixelShader: {
  71367. name: string;
  71368. shader: string;
  71369. };
  71370. }
  71371. declare module BABYLON {
  71372. /**
  71373. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71374. */
  71375. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71376. private _stepSize;
  71377. private _passedProcess;
  71378. /**
  71379. * Gets a string identifying the name of the class
  71380. * @returns "StereoscopicInterlacePostProcessI" string
  71381. */
  71382. getClassName(): string;
  71383. /**
  71384. * Initializes a StereoscopicInterlacePostProcessI
  71385. * @param name The name of the effect.
  71386. * @param rigCameras The rig cameras to be appled to the post process
  71387. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71388. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71390. * @param engine The engine which the post process will be applied. (default: current engine)
  71391. * @param reusable If the post process can be reused on the same frame. (default: false)
  71392. */
  71393. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71394. }
  71395. /**
  71396. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71397. */
  71398. export class StereoscopicInterlacePostProcess extends PostProcess {
  71399. private _stepSize;
  71400. private _passedProcess;
  71401. /**
  71402. * Gets a string identifying the name of the class
  71403. * @returns "StereoscopicInterlacePostProcess" string
  71404. */
  71405. getClassName(): string;
  71406. /**
  71407. * Initializes a StereoscopicInterlacePostProcess
  71408. * @param name The name of the effect.
  71409. * @param rigCameras The rig cameras to be appled to the post process
  71410. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71412. * @param engine The engine which the post process will be applied. (default: current engine)
  71413. * @param reusable If the post process can be reused on the same frame. (default: false)
  71414. */
  71415. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71416. }
  71417. }
  71418. declare module BABYLON {
  71419. /** @hidden */
  71420. export var tonemapPixelShader: {
  71421. name: string;
  71422. shader: string;
  71423. };
  71424. }
  71425. declare module BABYLON {
  71426. /** Defines operator used for tonemapping */
  71427. export enum TonemappingOperator {
  71428. /** Hable */
  71429. Hable = 0,
  71430. /** Reinhard */
  71431. Reinhard = 1,
  71432. /** HejiDawson */
  71433. HejiDawson = 2,
  71434. /** Photographic */
  71435. Photographic = 3
  71436. }
  71437. /**
  71438. * Defines a post process to apply tone mapping
  71439. */
  71440. export class TonemapPostProcess extends PostProcess {
  71441. private _operator;
  71442. /** Defines the required exposure adjustement */
  71443. exposureAdjustment: number;
  71444. /**
  71445. * Gets a string identifying the name of the class
  71446. * @returns "TonemapPostProcess" string
  71447. */
  71448. getClassName(): string;
  71449. /**
  71450. * Creates a new TonemapPostProcess
  71451. * @param name defines the name of the postprocess
  71452. * @param _operator defines the operator to use
  71453. * @param exposureAdjustment defines the required exposure adjustement
  71454. * @param camera defines the camera to use (can be null)
  71455. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71456. * @param engine defines the hosting engine (can be ignore if camera is set)
  71457. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71458. */
  71459. constructor(name: string, _operator: TonemappingOperator,
  71460. /** Defines the required exposure adjustement */
  71461. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71462. }
  71463. }
  71464. declare module BABYLON {
  71465. /** @hidden */
  71466. export var volumetricLightScatteringPixelShader: {
  71467. name: string;
  71468. shader: string;
  71469. };
  71470. }
  71471. declare module BABYLON {
  71472. /** @hidden */
  71473. export var volumetricLightScatteringPassVertexShader: {
  71474. name: string;
  71475. shader: string;
  71476. };
  71477. }
  71478. declare module BABYLON {
  71479. /** @hidden */
  71480. export var volumetricLightScatteringPassPixelShader: {
  71481. name: string;
  71482. shader: string;
  71483. };
  71484. }
  71485. declare module BABYLON {
  71486. /**
  71487. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71488. */
  71489. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71490. private _volumetricLightScatteringPass;
  71491. private _volumetricLightScatteringRTT;
  71492. private _viewPort;
  71493. private _screenCoordinates;
  71494. private _cachedDefines;
  71495. /**
  71496. * If not undefined, the mesh position is computed from the attached node position
  71497. */
  71498. attachedNode: {
  71499. position: Vector3;
  71500. };
  71501. /**
  71502. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71503. */
  71504. customMeshPosition: Vector3;
  71505. /**
  71506. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71507. */
  71508. useCustomMeshPosition: boolean;
  71509. /**
  71510. * If the post-process should inverse the light scattering direction
  71511. */
  71512. invert: boolean;
  71513. /**
  71514. * The internal mesh used by the post-process
  71515. */
  71516. mesh: Mesh;
  71517. /**
  71518. * @hidden
  71519. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71520. */
  71521. get useDiffuseColor(): boolean;
  71522. set useDiffuseColor(useDiffuseColor: boolean);
  71523. /**
  71524. * Array containing the excluded meshes not rendered in the internal pass
  71525. */
  71526. excludedMeshes: AbstractMesh[];
  71527. /**
  71528. * Controls the overall intensity of the post-process
  71529. */
  71530. exposure: number;
  71531. /**
  71532. * Dissipates each sample's contribution in range [0, 1]
  71533. */
  71534. decay: number;
  71535. /**
  71536. * Controls the overall intensity of each sample
  71537. */
  71538. weight: number;
  71539. /**
  71540. * Controls the density of each sample
  71541. */
  71542. density: number;
  71543. /**
  71544. * @constructor
  71545. * @param name The post-process name
  71546. * @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)
  71547. * @param camera The camera that the post-process will be attached to
  71548. * @param mesh The mesh used to create the light scattering
  71549. * @param samples The post-process quality, default 100
  71550. * @param samplingModeThe post-process filtering mode
  71551. * @param engine The babylon engine
  71552. * @param reusable If the post-process is reusable
  71553. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71554. */
  71555. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71556. /**
  71557. * Returns the string "VolumetricLightScatteringPostProcess"
  71558. * @returns "VolumetricLightScatteringPostProcess"
  71559. */
  71560. getClassName(): string;
  71561. private _isReady;
  71562. /**
  71563. * Sets the new light position for light scattering effect
  71564. * @param position The new custom light position
  71565. */
  71566. setCustomMeshPosition(position: Vector3): void;
  71567. /**
  71568. * Returns the light position for light scattering effect
  71569. * @return Vector3 The custom light position
  71570. */
  71571. getCustomMeshPosition(): Vector3;
  71572. /**
  71573. * Disposes the internal assets and detaches the post-process from the camera
  71574. */
  71575. dispose(camera: Camera): void;
  71576. /**
  71577. * Returns the render target texture used by the post-process
  71578. * @return the render target texture used by the post-process
  71579. */
  71580. getPass(): RenderTargetTexture;
  71581. private _meshExcluded;
  71582. private _createPass;
  71583. private _updateMeshScreenCoordinates;
  71584. /**
  71585. * Creates a default mesh for the Volumeric Light Scattering post-process
  71586. * @param name The mesh name
  71587. * @param scene The scene where to create the mesh
  71588. * @return the default mesh
  71589. */
  71590. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71591. }
  71592. }
  71593. declare module BABYLON {
  71594. /** @hidden */
  71595. export var screenSpaceCurvaturePixelShader: {
  71596. name: string;
  71597. shader: string;
  71598. };
  71599. }
  71600. declare module BABYLON {
  71601. /**
  71602. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71603. */
  71604. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71605. /**
  71606. * Defines how much ridge the curvature effect displays.
  71607. */
  71608. ridge: number;
  71609. /**
  71610. * Defines how much valley the curvature effect displays.
  71611. */
  71612. valley: number;
  71613. private _geometryBufferRenderer;
  71614. /**
  71615. * Gets a string identifying the name of the class
  71616. * @returns "ScreenSpaceCurvaturePostProcess" string
  71617. */
  71618. getClassName(): string;
  71619. /**
  71620. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71621. * @param name The name of the effect.
  71622. * @param scene The scene containing the objects to blur according to their velocity.
  71623. * @param options The required width/height ratio to downsize to before computing the render pass.
  71624. * @param camera The camera to apply the render pass to.
  71625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71626. * @param engine The engine which the post process will be applied. (default: current engine)
  71627. * @param reusable If the post process can be reused on the same frame. (default: false)
  71628. * @param textureType Type of textures used when performing the post process. (default: 0)
  71629. * @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)
  71630. */
  71631. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71632. /**
  71633. * Support test.
  71634. */
  71635. static get IsSupported(): boolean;
  71636. /** @hidden */
  71637. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71638. }
  71639. }
  71640. declare module BABYLON {
  71641. interface Scene {
  71642. /** @hidden (Backing field) */
  71643. _boundingBoxRenderer: BoundingBoxRenderer;
  71644. /** @hidden (Backing field) */
  71645. _forceShowBoundingBoxes: boolean;
  71646. /**
  71647. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71648. */
  71649. forceShowBoundingBoxes: boolean;
  71650. /**
  71651. * Gets the bounding box renderer associated with the scene
  71652. * @returns a BoundingBoxRenderer
  71653. */
  71654. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71655. }
  71656. interface AbstractMesh {
  71657. /** @hidden (Backing field) */
  71658. _showBoundingBox: boolean;
  71659. /**
  71660. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71661. */
  71662. showBoundingBox: boolean;
  71663. }
  71664. /**
  71665. * Component responsible of rendering the bounding box of the meshes in a scene.
  71666. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71667. */
  71668. export class BoundingBoxRenderer implements ISceneComponent {
  71669. /**
  71670. * The component name helpfull to identify the component in the list of scene components.
  71671. */
  71672. readonly name: string;
  71673. /**
  71674. * The scene the component belongs to.
  71675. */
  71676. scene: Scene;
  71677. /**
  71678. * Color of the bounding box lines placed in front of an object
  71679. */
  71680. frontColor: Color3;
  71681. /**
  71682. * Color of the bounding box lines placed behind an object
  71683. */
  71684. backColor: Color3;
  71685. /**
  71686. * Defines if the renderer should show the back lines or not
  71687. */
  71688. showBackLines: boolean;
  71689. /**
  71690. * Observable raised before rendering a bounding box
  71691. */
  71692. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71693. /**
  71694. * Observable raised after rendering a bounding box
  71695. */
  71696. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71697. /**
  71698. * @hidden
  71699. */
  71700. renderList: SmartArray<BoundingBox>;
  71701. private _colorShader;
  71702. private _vertexBuffers;
  71703. private _indexBuffer;
  71704. private _fillIndexBuffer;
  71705. private _fillIndexData;
  71706. /**
  71707. * Instantiates a new bounding box renderer in a scene.
  71708. * @param scene the scene the renderer renders in
  71709. */
  71710. constructor(scene: Scene);
  71711. /**
  71712. * Registers the component in a given scene
  71713. */
  71714. register(): void;
  71715. private _evaluateSubMesh;
  71716. private _activeMesh;
  71717. private _prepareRessources;
  71718. private _createIndexBuffer;
  71719. /**
  71720. * Rebuilds the elements related to this component in case of
  71721. * context lost for instance.
  71722. */
  71723. rebuild(): void;
  71724. /**
  71725. * @hidden
  71726. */
  71727. reset(): void;
  71728. /**
  71729. * Render the bounding boxes of a specific rendering group
  71730. * @param renderingGroupId defines the rendering group to render
  71731. */
  71732. render(renderingGroupId: number): void;
  71733. /**
  71734. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71735. * @param mesh Define the mesh to render the occlusion bounding box for
  71736. */
  71737. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71738. /**
  71739. * Dispose and release the resources attached to this renderer.
  71740. */
  71741. dispose(): void;
  71742. }
  71743. }
  71744. declare module BABYLON {
  71745. interface Scene {
  71746. /** @hidden (Backing field) */
  71747. _depthRenderer: {
  71748. [id: string]: DepthRenderer;
  71749. };
  71750. /**
  71751. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71752. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71753. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71754. * @returns the created depth renderer
  71755. */
  71756. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71757. /**
  71758. * Disables a depth renderer for a given camera
  71759. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71760. */
  71761. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71762. }
  71763. /**
  71764. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71765. * in several rendering techniques.
  71766. */
  71767. export class DepthRendererSceneComponent implements ISceneComponent {
  71768. /**
  71769. * The component name helpfull to identify the component in the list of scene components.
  71770. */
  71771. readonly name: string;
  71772. /**
  71773. * The scene the component belongs to.
  71774. */
  71775. scene: Scene;
  71776. /**
  71777. * Creates a new instance of the component for the given scene
  71778. * @param scene Defines the scene to register the component in
  71779. */
  71780. constructor(scene: Scene);
  71781. /**
  71782. * Registers the component in a given scene
  71783. */
  71784. register(): void;
  71785. /**
  71786. * Rebuilds the elements related to this component in case of
  71787. * context lost for instance.
  71788. */
  71789. rebuild(): void;
  71790. /**
  71791. * Disposes the component and the associated ressources
  71792. */
  71793. dispose(): void;
  71794. private _gatherRenderTargets;
  71795. private _gatherActiveCameraRenderTargets;
  71796. }
  71797. }
  71798. declare module BABYLON {
  71799. interface AbstractScene {
  71800. /** @hidden (Backing field) */
  71801. _prePassRenderer: Nullable<PrePassRenderer>;
  71802. /**
  71803. * Gets or Sets the current prepass renderer associated to the scene.
  71804. */
  71805. prePassRenderer: Nullable<PrePassRenderer>;
  71806. /**
  71807. * Enables the prepass and associates it with the scene
  71808. * @returns the PrePassRenderer
  71809. */
  71810. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71811. /**
  71812. * Disables the prepass associated with the scene
  71813. */
  71814. disablePrePassRenderer(): void;
  71815. }
  71816. /**
  71817. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71818. * in several rendering techniques.
  71819. */
  71820. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71821. /**
  71822. * The component name helpful to identify the component in the list of scene components.
  71823. */
  71824. readonly name: string;
  71825. /**
  71826. * The scene the component belongs to.
  71827. */
  71828. scene: Scene;
  71829. /**
  71830. * Creates a new instance of the component for the given scene
  71831. * @param scene Defines the scene to register the component in
  71832. */
  71833. constructor(scene: Scene);
  71834. /**
  71835. * Registers the component in a given scene
  71836. */
  71837. register(): void;
  71838. private _beforeCameraDraw;
  71839. private _afterCameraDraw;
  71840. private _beforeClearStage;
  71841. /**
  71842. * Serializes the component data to the specified json object
  71843. * @param serializationObject The object to serialize to
  71844. */
  71845. serialize(serializationObject: any): void;
  71846. /**
  71847. * Adds all the elements from the container to the scene
  71848. * @param container the container holding the elements
  71849. */
  71850. addFromContainer(container: AbstractScene): void;
  71851. /**
  71852. * Removes all the elements in the container from the scene
  71853. * @param container contains the elements to remove
  71854. * @param dispose if the removed element should be disposed (default: false)
  71855. */
  71856. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71857. /**
  71858. * Rebuilds the elements related to this component in case of
  71859. * context lost for instance.
  71860. */
  71861. rebuild(): void;
  71862. /**
  71863. * Disposes the component and the associated ressources
  71864. */
  71865. dispose(): void;
  71866. }
  71867. }
  71868. declare module BABYLON {
  71869. /** @hidden */
  71870. export var outlinePixelShader: {
  71871. name: string;
  71872. shader: string;
  71873. };
  71874. }
  71875. declare module BABYLON {
  71876. /** @hidden */
  71877. export var outlineVertexShader: {
  71878. name: string;
  71879. shader: string;
  71880. };
  71881. }
  71882. declare module BABYLON {
  71883. interface Scene {
  71884. /** @hidden */
  71885. _outlineRenderer: OutlineRenderer;
  71886. /**
  71887. * Gets the outline renderer associated with the scene
  71888. * @returns a OutlineRenderer
  71889. */
  71890. getOutlineRenderer(): OutlineRenderer;
  71891. }
  71892. interface AbstractMesh {
  71893. /** @hidden (Backing field) */
  71894. _renderOutline: boolean;
  71895. /**
  71896. * Gets or sets a boolean indicating if the outline must be rendered as well
  71897. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71898. */
  71899. renderOutline: boolean;
  71900. /** @hidden (Backing field) */
  71901. _renderOverlay: boolean;
  71902. /**
  71903. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71904. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71905. */
  71906. renderOverlay: boolean;
  71907. }
  71908. /**
  71909. * This class is responsible to draw bothe outline/overlay of meshes.
  71910. * It should not be used directly but through the available method on mesh.
  71911. */
  71912. export class OutlineRenderer implements ISceneComponent {
  71913. /**
  71914. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71915. */
  71916. private static _StencilReference;
  71917. /**
  71918. * The name of the component. Each component must have a unique name.
  71919. */
  71920. name: string;
  71921. /**
  71922. * The scene the component belongs to.
  71923. */
  71924. scene: Scene;
  71925. /**
  71926. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71927. */
  71928. zOffset: number;
  71929. private _engine;
  71930. private _effect;
  71931. private _cachedDefines;
  71932. private _savedDepthWrite;
  71933. /**
  71934. * Instantiates a new outline renderer. (There could be only one per scene).
  71935. * @param scene Defines the scene it belongs to
  71936. */
  71937. constructor(scene: Scene);
  71938. /**
  71939. * Register the component to one instance of a scene.
  71940. */
  71941. register(): void;
  71942. /**
  71943. * Rebuilds the elements related to this component in case of
  71944. * context lost for instance.
  71945. */
  71946. rebuild(): void;
  71947. /**
  71948. * Disposes the component and the associated ressources.
  71949. */
  71950. dispose(): void;
  71951. /**
  71952. * Renders the outline in the canvas.
  71953. * @param subMesh Defines the sumesh to render
  71954. * @param batch Defines the batch of meshes in case of instances
  71955. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71956. */
  71957. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71958. /**
  71959. * Returns whether or not the outline renderer is ready for a given submesh.
  71960. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71961. * @param subMesh Defines the submesh to check readyness for
  71962. * @param useInstances Defines wheter wee are trying to render instances or not
  71963. * @returns true if ready otherwise false
  71964. */
  71965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71966. private _beforeRenderingMesh;
  71967. private _afterRenderingMesh;
  71968. }
  71969. }
  71970. declare module BABYLON {
  71971. /**
  71972. * Defines the basic options interface of a Sprite Frame Source Size.
  71973. */
  71974. export interface ISpriteJSONSpriteSourceSize {
  71975. /**
  71976. * number of the original width of the Frame
  71977. */
  71978. w: number;
  71979. /**
  71980. * number of the original height of the Frame
  71981. */
  71982. h: number;
  71983. }
  71984. /**
  71985. * Defines the basic options interface of a Sprite Frame Data.
  71986. */
  71987. export interface ISpriteJSONSpriteFrameData {
  71988. /**
  71989. * number of the x offset of the Frame
  71990. */
  71991. x: number;
  71992. /**
  71993. * number of the y offset of the Frame
  71994. */
  71995. y: number;
  71996. /**
  71997. * number of the width of the Frame
  71998. */
  71999. w: number;
  72000. /**
  72001. * number of the height of the Frame
  72002. */
  72003. h: number;
  72004. }
  72005. /**
  72006. * Defines the basic options interface of a JSON Sprite.
  72007. */
  72008. export interface ISpriteJSONSprite {
  72009. /**
  72010. * string name of the Frame
  72011. */
  72012. filename: string;
  72013. /**
  72014. * ISpriteJSONSpriteFrame basic object of the frame data
  72015. */
  72016. frame: ISpriteJSONSpriteFrameData;
  72017. /**
  72018. * boolean to flag is the frame was rotated.
  72019. */
  72020. rotated: boolean;
  72021. /**
  72022. * boolean to flag is the frame was trimmed.
  72023. */
  72024. trimmed: boolean;
  72025. /**
  72026. * ISpriteJSONSpriteFrame basic object of the source data
  72027. */
  72028. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72029. /**
  72030. * ISpriteJSONSpriteFrame basic object of the source data
  72031. */
  72032. sourceSize: ISpriteJSONSpriteSourceSize;
  72033. }
  72034. /**
  72035. * Defines the basic options interface of a JSON atlas.
  72036. */
  72037. export interface ISpriteJSONAtlas {
  72038. /**
  72039. * Array of objects that contain the frame data.
  72040. */
  72041. frames: Array<ISpriteJSONSprite>;
  72042. /**
  72043. * object basic object containing the sprite meta data.
  72044. */
  72045. meta?: object;
  72046. }
  72047. }
  72048. declare module BABYLON {
  72049. /** @hidden */
  72050. export var spriteMapPixelShader: {
  72051. name: string;
  72052. shader: string;
  72053. };
  72054. }
  72055. declare module BABYLON {
  72056. /** @hidden */
  72057. export var spriteMapVertexShader: {
  72058. name: string;
  72059. shader: string;
  72060. };
  72061. }
  72062. declare module BABYLON {
  72063. /**
  72064. * Defines the basic options interface of a SpriteMap
  72065. */
  72066. export interface ISpriteMapOptions {
  72067. /**
  72068. * Vector2 of the number of cells in the grid.
  72069. */
  72070. stageSize?: Vector2;
  72071. /**
  72072. * Vector2 of the size of the output plane in World Units.
  72073. */
  72074. outputSize?: Vector2;
  72075. /**
  72076. * Vector3 of the position of the output plane in World Units.
  72077. */
  72078. outputPosition?: Vector3;
  72079. /**
  72080. * Vector3 of the rotation of the output plane.
  72081. */
  72082. outputRotation?: Vector3;
  72083. /**
  72084. * number of layers that the system will reserve in resources.
  72085. */
  72086. layerCount?: number;
  72087. /**
  72088. * number of max animation frames a single cell will reserve in resources.
  72089. */
  72090. maxAnimationFrames?: number;
  72091. /**
  72092. * number cell index of the base tile when the system compiles.
  72093. */
  72094. baseTile?: number;
  72095. /**
  72096. * boolean flip the sprite after its been repositioned by the framing data.
  72097. */
  72098. flipU?: boolean;
  72099. /**
  72100. * Vector3 scalar of the global RGB values of the SpriteMap.
  72101. */
  72102. colorMultiply?: Vector3;
  72103. }
  72104. /**
  72105. * Defines the IDisposable interface in order to be cleanable from resources.
  72106. */
  72107. export interface ISpriteMap extends IDisposable {
  72108. /**
  72109. * String name of the SpriteMap.
  72110. */
  72111. name: string;
  72112. /**
  72113. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72114. */
  72115. atlasJSON: ISpriteJSONAtlas;
  72116. /**
  72117. * Texture of the SpriteMap.
  72118. */
  72119. spriteSheet: Texture;
  72120. /**
  72121. * The parameters to initialize the SpriteMap with.
  72122. */
  72123. options: ISpriteMapOptions;
  72124. }
  72125. /**
  72126. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72127. */
  72128. export class SpriteMap implements ISpriteMap {
  72129. /** The Name of the spriteMap */
  72130. name: string;
  72131. /** The JSON file with the frame and meta data */
  72132. atlasJSON: ISpriteJSONAtlas;
  72133. /** The systems Sprite Sheet Texture */
  72134. spriteSheet: Texture;
  72135. /** Arguments passed with the Constructor */
  72136. options: ISpriteMapOptions;
  72137. /** Public Sprite Storage array, parsed from atlasJSON */
  72138. sprites: Array<ISpriteJSONSprite>;
  72139. /** Returns the Number of Sprites in the System */
  72140. get spriteCount(): number;
  72141. /** Returns the Position of Output Plane*/
  72142. get position(): Vector3;
  72143. /** Returns the Position of Output Plane*/
  72144. set position(v: Vector3);
  72145. /** Returns the Rotation of Output Plane*/
  72146. get rotation(): Vector3;
  72147. /** Returns the Rotation of Output Plane*/
  72148. set rotation(v: Vector3);
  72149. /** Sets the AnimationMap*/
  72150. get animationMap(): RawTexture;
  72151. /** Sets the AnimationMap*/
  72152. set animationMap(v: RawTexture);
  72153. /** Scene that the SpriteMap was created in */
  72154. private _scene;
  72155. /** Texture Buffer of Float32 that holds tile frame data*/
  72156. private _frameMap;
  72157. /** Texture Buffers of Float32 that holds tileMap data*/
  72158. private _tileMaps;
  72159. /** Texture Buffer of Float32 that holds Animation Data*/
  72160. private _animationMap;
  72161. /** Custom ShaderMaterial Central to the System*/
  72162. private _material;
  72163. /** Custom ShaderMaterial Central to the System*/
  72164. private _output;
  72165. /** Systems Time Ticker*/
  72166. private _time;
  72167. /**
  72168. * Creates a new SpriteMap
  72169. * @param name defines the SpriteMaps Name
  72170. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72171. * @param spriteSheet is the Texture that the Sprites are on.
  72172. * @param options a basic deployment configuration
  72173. * @param scene The Scene that the map is deployed on
  72174. */
  72175. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72176. /**
  72177. * Returns tileID location
  72178. * @returns Vector2 the cell position ID
  72179. */
  72180. getTileID(): Vector2;
  72181. /**
  72182. * Gets the UV location of the mouse over the SpriteMap.
  72183. * @returns Vector2 the UV position of the mouse interaction
  72184. */
  72185. getMousePosition(): Vector2;
  72186. /**
  72187. * Creates the "frame" texture Buffer
  72188. * -------------------------------------
  72189. * Structure of frames
  72190. * "filename": "Falling-Water-2.png",
  72191. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72192. * "rotated": true,
  72193. * "trimmed": true,
  72194. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72195. * "sourceSize": {"w":32,"h":32}
  72196. * @returns RawTexture of the frameMap
  72197. */
  72198. private _createFrameBuffer;
  72199. /**
  72200. * Creates the tileMap texture Buffer
  72201. * @param buffer normally and array of numbers, or a false to generate from scratch
  72202. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72203. * @returns RawTexture of the tileMap
  72204. */
  72205. private _createTileBuffer;
  72206. /**
  72207. * Modifies the data of the tileMaps
  72208. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72209. * @param pos is the iVector2 Coordinates of the Tile
  72210. * @param tile The SpriteIndex of the new Tile
  72211. */
  72212. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72213. /**
  72214. * Creates the animationMap texture Buffer
  72215. * @param buffer normally and array of numbers, or a false to generate from scratch
  72216. * @returns RawTexture of the animationMap
  72217. */
  72218. private _createTileAnimationBuffer;
  72219. /**
  72220. * Modifies the data of the animationMap
  72221. * @param cellID is the Index of the Sprite
  72222. * @param _frame is the target Animation frame
  72223. * @param toCell is the Target Index of the next frame of the animation
  72224. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72225. * @param speed is a global scalar of the time variable on the map.
  72226. */
  72227. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72228. /**
  72229. * Exports the .tilemaps file
  72230. */
  72231. saveTileMaps(): void;
  72232. /**
  72233. * Imports the .tilemaps file
  72234. * @param url of the .tilemaps file
  72235. */
  72236. loadTileMaps(url: string): void;
  72237. /**
  72238. * Release associated resources
  72239. */
  72240. dispose(): void;
  72241. }
  72242. }
  72243. declare module BABYLON {
  72244. /**
  72245. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72246. * @see https://doc.babylonjs.com/babylon101/sprites
  72247. */
  72248. export class SpritePackedManager extends SpriteManager {
  72249. /** defines the packed manager's name */
  72250. name: string;
  72251. /**
  72252. * Creates a new sprite manager from a packed sprite sheet
  72253. * @param name defines the manager's name
  72254. * @param imgUrl defines the sprite sheet url
  72255. * @param capacity defines the maximum allowed number of sprites
  72256. * @param scene defines the hosting scene
  72257. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72258. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72259. * @param samplingMode defines the smapling mode to use with spritesheet
  72260. * @param fromPacked set to true; do not alter
  72261. */
  72262. constructor(
  72263. /** defines the packed manager's name */
  72264. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72265. }
  72266. }
  72267. declare module BABYLON {
  72268. /**
  72269. * Defines the list of states available for a task inside a AssetsManager
  72270. */
  72271. export enum AssetTaskState {
  72272. /**
  72273. * Initialization
  72274. */
  72275. INIT = 0,
  72276. /**
  72277. * Running
  72278. */
  72279. RUNNING = 1,
  72280. /**
  72281. * Done
  72282. */
  72283. DONE = 2,
  72284. /**
  72285. * Error
  72286. */
  72287. ERROR = 3
  72288. }
  72289. /**
  72290. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72291. */
  72292. export abstract class AbstractAssetTask {
  72293. /**
  72294. * Task name
  72295. */ name: string;
  72296. /**
  72297. * Callback called when the task is successful
  72298. */
  72299. onSuccess: (task: any) => void;
  72300. /**
  72301. * Callback called when the task is not successful
  72302. */
  72303. onError: (task: any, message?: string, exception?: any) => void;
  72304. /**
  72305. * Creates a new AssetsManager
  72306. * @param name defines the name of the task
  72307. */
  72308. constructor(
  72309. /**
  72310. * Task name
  72311. */ name: string);
  72312. private _isCompleted;
  72313. private _taskState;
  72314. private _errorObject;
  72315. /**
  72316. * Get if the task is completed
  72317. */
  72318. get isCompleted(): boolean;
  72319. /**
  72320. * Gets the current state of the task
  72321. */
  72322. get taskState(): AssetTaskState;
  72323. /**
  72324. * Gets the current error object (if task is in error)
  72325. */
  72326. get errorObject(): {
  72327. message?: string;
  72328. exception?: any;
  72329. };
  72330. /**
  72331. * Internal only
  72332. * @hidden
  72333. */
  72334. _setErrorObject(message?: string, exception?: any): void;
  72335. /**
  72336. * Execute the current task
  72337. * @param scene defines the scene where you want your assets to be loaded
  72338. * @param onSuccess is a callback called when the task is successfully executed
  72339. * @param onError is a callback called if an error occurs
  72340. */
  72341. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72342. /**
  72343. * Execute the current task
  72344. * @param scene defines the scene where you want your assets to be loaded
  72345. * @param onSuccess is a callback called when the task is successfully executed
  72346. * @param onError is a callback called if an error occurs
  72347. */
  72348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72349. /**
  72350. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72351. * This can be used with failed tasks that have the reason for failure fixed.
  72352. */
  72353. reset(): void;
  72354. private onErrorCallback;
  72355. private onDoneCallback;
  72356. }
  72357. /**
  72358. * Define the interface used by progress events raised during assets loading
  72359. */
  72360. export interface IAssetsProgressEvent {
  72361. /**
  72362. * Defines the number of remaining tasks to process
  72363. */
  72364. remainingCount: number;
  72365. /**
  72366. * Defines the total number of tasks
  72367. */
  72368. totalCount: number;
  72369. /**
  72370. * Defines the task that was just processed
  72371. */
  72372. task: AbstractAssetTask;
  72373. }
  72374. /**
  72375. * Class used to share progress information about assets loading
  72376. */
  72377. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72378. /**
  72379. * Defines the number of remaining tasks to process
  72380. */
  72381. remainingCount: number;
  72382. /**
  72383. * Defines the total number of tasks
  72384. */
  72385. totalCount: number;
  72386. /**
  72387. * Defines the task that was just processed
  72388. */
  72389. task: AbstractAssetTask;
  72390. /**
  72391. * Creates a AssetsProgressEvent
  72392. * @param remainingCount defines the number of remaining tasks to process
  72393. * @param totalCount defines the total number of tasks
  72394. * @param task defines the task that was just processed
  72395. */
  72396. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72397. }
  72398. /**
  72399. * Define a task used by AssetsManager to load assets into a container
  72400. */
  72401. export class ContainerAssetTask extends AbstractAssetTask {
  72402. /**
  72403. * Defines the name of the task
  72404. */
  72405. name: string;
  72406. /**
  72407. * Defines the list of mesh's names you want to load
  72408. */
  72409. meshesNames: any;
  72410. /**
  72411. * Defines the root url to use as a base to load your meshes and associated resources
  72412. */
  72413. rootUrl: string;
  72414. /**
  72415. * Defines the filename or File of the scene to load from
  72416. */
  72417. sceneFilename: string | File;
  72418. /**
  72419. * Get the loaded asset container
  72420. */
  72421. loadedContainer: AssetContainer;
  72422. /**
  72423. * Gets the list of loaded meshes
  72424. */
  72425. loadedMeshes: Array<AbstractMesh>;
  72426. /**
  72427. * Gets the list of loaded particle systems
  72428. */
  72429. loadedParticleSystems: Array<IParticleSystem>;
  72430. /**
  72431. * Gets the list of loaded skeletons
  72432. */
  72433. loadedSkeletons: Array<Skeleton>;
  72434. /**
  72435. * Gets the list of loaded animation groups
  72436. */
  72437. loadedAnimationGroups: Array<AnimationGroup>;
  72438. /**
  72439. * Callback called when the task is successful
  72440. */
  72441. onSuccess: (task: ContainerAssetTask) => void;
  72442. /**
  72443. * Callback called when the task is successful
  72444. */
  72445. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72446. /**
  72447. * Creates a new ContainerAssetTask
  72448. * @param name defines the name of the task
  72449. * @param meshesNames defines the list of mesh's names you want to load
  72450. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72451. * @param sceneFilename defines the filename or File of the scene to load from
  72452. */
  72453. constructor(
  72454. /**
  72455. * Defines the name of the task
  72456. */
  72457. name: string,
  72458. /**
  72459. * Defines the list of mesh's names you want to load
  72460. */
  72461. meshesNames: any,
  72462. /**
  72463. * Defines the root url to use as a base to load your meshes and associated resources
  72464. */
  72465. rootUrl: string,
  72466. /**
  72467. * Defines the filename or File of the scene to load from
  72468. */
  72469. sceneFilename: string | File);
  72470. /**
  72471. * Execute the current task
  72472. * @param scene defines the scene where you want your assets to be loaded
  72473. * @param onSuccess is a callback called when the task is successfully executed
  72474. * @param onError is a callback called if an error occurs
  72475. */
  72476. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72477. }
  72478. /**
  72479. * Define a task used by AssetsManager to load meshes
  72480. */
  72481. export class MeshAssetTask extends AbstractAssetTask {
  72482. /**
  72483. * Defines the name of the task
  72484. */
  72485. name: string;
  72486. /**
  72487. * Defines the list of mesh's names you want to load
  72488. */
  72489. meshesNames: any;
  72490. /**
  72491. * Defines the root url to use as a base to load your meshes and associated resources
  72492. */
  72493. rootUrl: string;
  72494. /**
  72495. * Defines the filename or File of the scene to load from
  72496. */
  72497. sceneFilename: string | File;
  72498. /**
  72499. * Gets the list of loaded meshes
  72500. */
  72501. loadedMeshes: Array<AbstractMesh>;
  72502. /**
  72503. * Gets the list of loaded particle systems
  72504. */
  72505. loadedParticleSystems: Array<IParticleSystem>;
  72506. /**
  72507. * Gets the list of loaded skeletons
  72508. */
  72509. loadedSkeletons: Array<Skeleton>;
  72510. /**
  72511. * Gets the list of loaded animation groups
  72512. */
  72513. loadedAnimationGroups: Array<AnimationGroup>;
  72514. /**
  72515. * Callback called when the task is successful
  72516. */
  72517. onSuccess: (task: MeshAssetTask) => void;
  72518. /**
  72519. * Callback called when the task is successful
  72520. */
  72521. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72522. /**
  72523. * Creates a new MeshAssetTask
  72524. * @param name defines the name of the task
  72525. * @param meshesNames defines the list of mesh's names you want to load
  72526. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72527. * @param sceneFilename defines the filename or File of the scene to load from
  72528. */
  72529. constructor(
  72530. /**
  72531. * Defines the name of the task
  72532. */
  72533. name: string,
  72534. /**
  72535. * Defines the list of mesh's names you want to load
  72536. */
  72537. meshesNames: any,
  72538. /**
  72539. * Defines the root url to use as a base to load your meshes and associated resources
  72540. */
  72541. rootUrl: string,
  72542. /**
  72543. * Defines the filename or File of the scene to load from
  72544. */
  72545. sceneFilename: string | File);
  72546. /**
  72547. * Execute the current task
  72548. * @param scene defines the scene where you want your assets to be loaded
  72549. * @param onSuccess is a callback called when the task is successfully executed
  72550. * @param onError is a callback called if an error occurs
  72551. */
  72552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72553. }
  72554. /**
  72555. * Define a task used by AssetsManager to load text content
  72556. */
  72557. export class TextFileAssetTask extends AbstractAssetTask {
  72558. /**
  72559. * Defines the name of the task
  72560. */
  72561. name: string;
  72562. /**
  72563. * Defines the location of the file to load
  72564. */
  72565. url: string;
  72566. /**
  72567. * Gets the loaded text string
  72568. */
  72569. text: string;
  72570. /**
  72571. * Callback called when the task is successful
  72572. */
  72573. onSuccess: (task: TextFileAssetTask) => void;
  72574. /**
  72575. * Callback called when the task is successful
  72576. */
  72577. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72578. /**
  72579. * Creates a new TextFileAssetTask object
  72580. * @param name defines the name of the task
  72581. * @param url defines the location of the file to load
  72582. */
  72583. constructor(
  72584. /**
  72585. * Defines the name of the task
  72586. */
  72587. name: string,
  72588. /**
  72589. * Defines the location of the file to load
  72590. */
  72591. url: string);
  72592. /**
  72593. * Execute the current task
  72594. * @param scene defines the scene where you want your assets to be loaded
  72595. * @param onSuccess is a callback called when the task is successfully executed
  72596. * @param onError is a callback called if an error occurs
  72597. */
  72598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72599. }
  72600. /**
  72601. * Define a task used by AssetsManager to load binary data
  72602. */
  72603. export class BinaryFileAssetTask extends AbstractAssetTask {
  72604. /**
  72605. * Defines the name of the task
  72606. */
  72607. name: string;
  72608. /**
  72609. * Defines the location of the file to load
  72610. */
  72611. url: string;
  72612. /**
  72613. * Gets the lodaded data (as an array buffer)
  72614. */
  72615. data: ArrayBuffer;
  72616. /**
  72617. * Callback called when the task is successful
  72618. */
  72619. onSuccess: (task: BinaryFileAssetTask) => void;
  72620. /**
  72621. * Callback called when the task is successful
  72622. */
  72623. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72624. /**
  72625. * Creates a new BinaryFileAssetTask object
  72626. * @param name defines the name of the new task
  72627. * @param url defines the location of the file to load
  72628. */
  72629. constructor(
  72630. /**
  72631. * Defines the name of the task
  72632. */
  72633. name: string,
  72634. /**
  72635. * Defines the location of the file to load
  72636. */
  72637. url: string);
  72638. /**
  72639. * Execute the current task
  72640. * @param scene defines the scene where you want your assets to be loaded
  72641. * @param onSuccess is a callback called when the task is successfully executed
  72642. * @param onError is a callback called if an error occurs
  72643. */
  72644. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72645. }
  72646. /**
  72647. * Define a task used by AssetsManager to load images
  72648. */
  72649. export class ImageAssetTask extends AbstractAssetTask {
  72650. /**
  72651. * Defines the name of the task
  72652. */
  72653. name: string;
  72654. /**
  72655. * Defines the location of the image to load
  72656. */
  72657. url: string;
  72658. /**
  72659. * Gets the loaded images
  72660. */
  72661. image: HTMLImageElement;
  72662. /**
  72663. * Callback called when the task is successful
  72664. */
  72665. onSuccess: (task: ImageAssetTask) => void;
  72666. /**
  72667. * Callback called when the task is successful
  72668. */
  72669. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72670. /**
  72671. * Creates a new ImageAssetTask
  72672. * @param name defines the name of the task
  72673. * @param url defines the location of the image to load
  72674. */
  72675. constructor(
  72676. /**
  72677. * Defines the name of the task
  72678. */
  72679. name: string,
  72680. /**
  72681. * Defines the location of the image to load
  72682. */
  72683. url: string);
  72684. /**
  72685. * Execute the current task
  72686. * @param scene defines the scene where you want your assets to be loaded
  72687. * @param onSuccess is a callback called when the task is successfully executed
  72688. * @param onError is a callback called if an error occurs
  72689. */
  72690. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72691. }
  72692. /**
  72693. * Defines the interface used by texture loading tasks
  72694. */
  72695. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72696. /**
  72697. * Gets the loaded texture
  72698. */
  72699. texture: TEX;
  72700. }
  72701. /**
  72702. * Define a task used by AssetsManager to load 2D textures
  72703. */
  72704. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72705. /**
  72706. * Defines the name of the task
  72707. */
  72708. name: string;
  72709. /**
  72710. * Defines the location of the file to load
  72711. */
  72712. url: string;
  72713. /**
  72714. * Defines if mipmap should not be generated (default is false)
  72715. */
  72716. noMipmap?: boolean | undefined;
  72717. /**
  72718. * Defines if texture must be inverted on Y axis (default is true)
  72719. */
  72720. invertY: boolean;
  72721. /**
  72722. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72723. */
  72724. samplingMode: number;
  72725. /**
  72726. * Gets the loaded texture
  72727. */
  72728. texture: Texture;
  72729. /**
  72730. * Callback called when the task is successful
  72731. */
  72732. onSuccess: (task: TextureAssetTask) => void;
  72733. /**
  72734. * Callback called when the task is successful
  72735. */
  72736. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72737. /**
  72738. * Creates a new TextureAssetTask object
  72739. * @param name defines the name of the task
  72740. * @param url defines the location of the file to load
  72741. * @param noMipmap defines if mipmap should not be generated (default is false)
  72742. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72743. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72744. */
  72745. constructor(
  72746. /**
  72747. * Defines the name of the task
  72748. */
  72749. name: string,
  72750. /**
  72751. * Defines the location of the file to load
  72752. */
  72753. url: string,
  72754. /**
  72755. * Defines if mipmap should not be generated (default is false)
  72756. */
  72757. noMipmap?: boolean | undefined,
  72758. /**
  72759. * Defines if texture must be inverted on Y axis (default is true)
  72760. */
  72761. invertY?: boolean,
  72762. /**
  72763. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72764. */
  72765. samplingMode?: number);
  72766. /**
  72767. * Execute the current task
  72768. * @param scene defines the scene where you want your assets to be loaded
  72769. * @param onSuccess is a callback called when the task is successfully executed
  72770. * @param onError is a callback called if an error occurs
  72771. */
  72772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72773. }
  72774. /**
  72775. * Define a task used by AssetsManager to load cube textures
  72776. */
  72777. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72778. /**
  72779. * Defines the name of the task
  72780. */
  72781. name: string;
  72782. /**
  72783. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72784. */
  72785. url: string;
  72786. /**
  72787. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72788. */
  72789. extensions?: string[] | undefined;
  72790. /**
  72791. * Defines if mipmaps should not be generated (default is false)
  72792. */
  72793. noMipmap?: boolean | undefined;
  72794. /**
  72795. * Defines the explicit list of files (undefined by default)
  72796. */
  72797. files?: string[] | undefined;
  72798. /**
  72799. * Gets the loaded texture
  72800. */
  72801. texture: CubeTexture;
  72802. /**
  72803. * Callback called when the task is successful
  72804. */
  72805. onSuccess: (task: CubeTextureAssetTask) => void;
  72806. /**
  72807. * Callback called when the task is successful
  72808. */
  72809. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72810. /**
  72811. * Creates a new CubeTextureAssetTask
  72812. * @param name defines the name of the task
  72813. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72814. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72815. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72816. * @param files defines the explicit list of files (undefined by default)
  72817. */
  72818. constructor(
  72819. /**
  72820. * Defines the name of the task
  72821. */
  72822. name: string,
  72823. /**
  72824. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72825. */
  72826. url: string,
  72827. /**
  72828. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72829. */
  72830. extensions?: string[] | undefined,
  72831. /**
  72832. * Defines if mipmaps should not be generated (default is false)
  72833. */
  72834. noMipmap?: boolean | undefined,
  72835. /**
  72836. * Defines the explicit list of files (undefined by default)
  72837. */
  72838. files?: string[] | undefined);
  72839. /**
  72840. * Execute the current task
  72841. * @param scene defines the scene where you want your assets to be loaded
  72842. * @param onSuccess is a callback called when the task is successfully executed
  72843. * @param onError is a callback called if an error occurs
  72844. */
  72845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72846. }
  72847. /**
  72848. * Define a task used by AssetsManager to load HDR cube textures
  72849. */
  72850. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72851. /**
  72852. * Defines the name of the task
  72853. */
  72854. name: string;
  72855. /**
  72856. * Defines the location of the file to load
  72857. */
  72858. url: string;
  72859. /**
  72860. * Defines the desired size (the more it increases the longer the generation will be)
  72861. */
  72862. size: number;
  72863. /**
  72864. * Defines if mipmaps should not be generated (default is false)
  72865. */
  72866. noMipmap: boolean;
  72867. /**
  72868. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72869. */
  72870. generateHarmonics: boolean;
  72871. /**
  72872. * 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)
  72873. */
  72874. gammaSpace: boolean;
  72875. /**
  72876. * Internal Use Only
  72877. */
  72878. reserved: boolean;
  72879. /**
  72880. * Gets the loaded texture
  72881. */
  72882. texture: HDRCubeTexture;
  72883. /**
  72884. * Callback called when the task is successful
  72885. */
  72886. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72887. /**
  72888. * Callback called when the task is successful
  72889. */
  72890. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72891. /**
  72892. * Creates a new HDRCubeTextureAssetTask object
  72893. * @param name defines the name of the task
  72894. * @param url defines the location of the file to load
  72895. * @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.
  72896. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72897. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72898. * @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)
  72899. * @param reserved Internal use only
  72900. */
  72901. constructor(
  72902. /**
  72903. * Defines the name of the task
  72904. */
  72905. name: string,
  72906. /**
  72907. * Defines the location of the file to load
  72908. */
  72909. url: string,
  72910. /**
  72911. * Defines the desired size (the more it increases the longer the generation will be)
  72912. */
  72913. size: number,
  72914. /**
  72915. * Defines if mipmaps should not be generated (default is false)
  72916. */
  72917. noMipmap?: boolean,
  72918. /**
  72919. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72920. */
  72921. generateHarmonics?: boolean,
  72922. /**
  72923. * 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)
  72924. */
  72925. gammaSpace?: boolean,
  72926. /**
  72927. * Internal Use Only
  72928. */
  72929. reserved?: boolean);
  72930. /**
  72931. * Execute the current task
  72932. * @param scene defines the scene where you want your assets to be loaded
  72933. * @param onSuccess is a callback called when the task is successfully executed
  72934. * @param onError is a callback called if an error occurs
  72935. */
  72936. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72937. }
  72938. /**
  72939. * Define a task used by AssetsManager to load Equirectangular cube textures
  72940. */
  72941. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72942. /**
  72943. * Defines the name of the task
  72944. */
  72945. name: string;
  72946. /**
  72947. * Defines the location of the file to load
  72948. */
  72949. url: string;
  72950. /**
  72951. * Defines the desired size (the more it increases the longer the generation will be)
  72952. */
  72953. size: number;
  72954. /**
  72955. * Defines if mipmaps should not be generated (default is false)
  72956. */
  72957. noMipmap: boolean;
  72958. /**
  72959. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72960. * but the standard material would require them in Gamma space) (default is true)
  72961. */
  72962. gammaSpace: boolean;
  72963. /**
  72964. * Gets the loaded texture
  72965. */
  72966. texture: EquiRectangularCubeTexture;
  72967. /**
  72968. * Callback called when the task is successful
  72969. */
  72970. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72971. /**
  72972. * Callback called when the task is successful
  72973. */
  72974. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72975. /**
  72976. * Creates a new EquiRectangularCubeTextureAssetTask object
  72977. * @param name defines the name of the task
  72978. * @param url defines the location of the file to load
  72979. * @param size defines the desired size (the more it increases the longer the generation will be)
  72980. * If the size is omitted this implies you are using a preprocessed cubemap.
  72981. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72982. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72983. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72984. * (default is true)
  72985. */
  72986. constructor(
  72987. /**
  72988. * Defines the name of the task
  72989. */
  72990. name: string,
  72991. /**
  72992. * Defines the location of the file to load
  72993. */
  72994. url: string,
  72995. /**
  72996. * Defines the desired size (the more it increases the longer the generation will be)
  72997. */
  72998. size: number,
  72999. /**
  73000. * Defines if mipmaps should not be generated (default is false)
  73001. */
  73002. noMipmap?: boolean,
  73003. /**
  73004. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73005. * but the standard material would require them in Gamma space) (default is true)
  73006. */
  73007. gammaSpace?: boolean);
  73008. /**
  73009. * Execute the current task
  73010. * @param scene defines the scene where you want your assets to be loaded
  73011. * @param onSuccess is a callback called when the task is successfully executed
  73012. * @param onError is a callback called if an error occurs
  73013. */
  73014. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73015. }
  73016. /**
  73017. * This class can be used to easily import assets into a scene
  73018. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73019. */
  73020. export class AssetsManager {
  73021. private _scene;
  73022. private _isLoading;
  73023. protected _tasks: AbstractAssetTask[];
  73024. protected _waitingTasksCount: number;
  73025. protected _totalTasksCount: number;
  73026. /**
  73027. * Callback called when all tasks are processed
  73028. */
  73029. onFinish: (tasks: AbstractAssetTask[]) => void;
  73030. /**
  73031. * Callback called when a task is successful
  73032. */
  73033. onTaskSuccess: (task: AbstractAssetTask) => void;
  73034. /**
  73035. * Callback called when a task had an error
  73036. */
  73037. onTaskError: (task: AbstractAssetTask) => void;
  73038. /**
  73039. * Callback called when a task is done (whatever the result is)
  73040. */
  73041. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73042. /**
  73043. * Observable called when all tasks are processed
  73044. */
  73045. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73046. /**
  73047. * Observable called when a task had an error
  73048. */
  73049. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73050. /**
  73051. * Observable called when all tasks were executed
  73052. */
  73053. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73054. /**
  73055. * Observable called when a task is done (whatever the result is)
  73056. */
  73057. onProgressObservable: Observable<IAssetsProgressEvent>;
  73058. /**
  73059. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73060. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73061. */
  73062. useDefaultLoadingScreen: boolean;
  73063. /**
  73064. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73065. * when all assets have been downloaded.
  73066. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73067. */
  73068. autoHideLoadingUI: boolean;
  73069. /**
  73070. * Creates a new AssetsManager
  73071. * @param scene defines the scene to work on
  73072. */
  73073. constructor(scene: Scene);
  73074. /**
  73075. * Add a ContainerAssetTask to the list of active tasks
  73076. * @param taskName defines the name of the new task
  73077. * @param meshesNames defines the name of meshes to load
  73078. * @param rootUrl defines the root url to use to locate files
  73079. * @param sceneFilename defines the filename of the scene file
  73080. * @returns a new ContainerAssetTask object
  73081. */
  73082. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73083. /**
  73084. * Add a MeshAssetTask to the list of active tasks
  73085. * @param taskName defines the name of the new task
  73086. * @param meshesNames defines the name of meshes to load
  73087. * @param rootUrl defines the root url to use to locate files
  73088. * @param sceneFilename defines the filename of the scene file
  73089. * @returns a new MeshAssetTask object
  73090. */
  73091. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73092. /**
  73093. * Add a TextFileAssetTask to the list of active tasks
  73094. * @param taskName defines the name of the new task
  73095. * @param url defines the url of the file to load
  73096. * @returns a new TextFileAssetTask object
  73097. */
  73098. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73099. /**
  73100. * Add a BinaryFileAssetTask to the list of active tasks
  73101. * @param taskName defines the name of the new task
  73102. * @param url defines the url of the file to load
  73103. * @returns a new BinaryFileAssetTask object
  73104. */
  73105. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73106. /**
  73107. * Add a ImageAssetTask to the list of active tasks
  73108. * @param taskName defines the name of the new task
  73109. * @param url defines the url of the file to load
  73110. * @returns a new ImageAssetTask object
  73111. */
  73112. addImageTask(taskName: string, url: string): ImageAssetTask;
  73113. /**
  73114. * Add a TextureAssetTask to the list of active tasks
  73115. * @param taskName defines the name of the new task
  73116. * @param url defines the url of the file to load
  73117. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73118. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73119. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73120. * @returns a new TextureAssetTask object
  73121. */
  73122. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73123. /**
  73124. * Add a CubeTextureAssetTask to the list of active tasks
  73125. * @param taskName defines the name of the new task
  73126. * @param url defines the url of the file to load
  73127. * @param extensions defines the extension to use to load the cube map (can be null)
  73128. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73129. * @param files defines the list of files to load (can be null)
  73130. * @returns a new CubeTextureAssetTask object
  73131. */
  73132. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73133. /**
  73134. *
  73135. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73136. * @param taskName defines the name of the new task
  73137. * @param url defines the url of the file to load
  73138. * @param size defines the size you want for the cubemap (can be null)
  73139. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73140. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73141. * @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)
  73142. * @param reserved Internal use only
  73143. * @returns a new HDRCubeTextureAssetTask object
  73144. */
  73145. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73146. /**
  73147. *
  73148. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73149. * @param taskName defines the name of the new task
  73150. * @param url defines the url of the file to load
  73151. * @param size defines the size you want for the cubemap (can be null)
  73152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73153. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73154. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73155. * @returns a new EquiRectangularCubeTextureAssetTask object
  73156. */
  73157. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73158. /**
  73159. * Remove a task from the assets manager.
  73160. * @param task the task to remove
  73161. */
  73162. removeTask(task: AbstractAssetTask): void;
  73163. private _decreaseWaitingTasksCount;
  73164. private _runTask;
  73165. /**
  73166. * Reset the AssetsManager and remove all tasks
  73167. * @return the current instance of the AssetsManager
  73168. */
  73169. reset(): AssetsManager;
  73170. /**
  73171. * Start the loading process
  73172. * @return the current instance of the AssetsManager
  73173. */
  73174. load(): AssetsManager;
  73175. /**
  73176. * Start the loading process as an async operation
  73177. * @return a promise returning the list of failed tasks
  73178. */
  73179. loadAsync(): Promise<void>;
  73180. }
  73181. }
  73182. declare module BABYLON {
  73183. /**
  73184. * Wrapper class for promise with external resolve and reject.
  73185. */
  73186. export class Deferred<T> {
  73187. /**
  73188. * The promise associated with this deferred object.
  73189. */
  73190. readonly promise: Promise<T>;
  73191. private _resolve;
  73192. private _reject;
  73193. /**
  73194. * The resolve method of the promise associated with this deferred object.
  73195. */
  73196. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73197. /**
  73198. * The reject method of the promise associated with this deferred object.
  73199. */
  73200. get reject(): (reason?: any) => void;
  73201. /**
  73202. * Constructor for this deferred object.
  73203. */
  73204. constructor();
  73205. }
  73206. }
  73207. declare module BABYLON {
  73208. /**
  73209. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73210. */
  73211. export class MeshExploder {
  73212. private _centerMesh;
  73213. private _meshes;
  73214. private _meshesOrigins;
  73215. private _toCenterVectors;
  73216. private _scaledDirection;
  73217. private _newPosition;
  73218. private _centerPosition;
  73219. /**
  73220. * Explodes meshes from a center mesh.
  73221. * @param meshes The meshes to explode.
  73222. * @param centerMesh The mesh to be center of explosion.
  73223. */
  73224. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73225. private _setCenterMesh;
  73226. /**
  73227. * Get class name
  73228. * @returns "MeshExploder"
  73229. */
  73230. getClassName(): string;
  73231. /**
  73232. * "Exploded meshes"
  73233. * @returns Array of meshes with the centerMesh at index 0.
  73234. */
  73235. getMeshes(): Array<Mesh>;
  73236. /**
  73237. * Explodes meshes giving a specific direction
  73238. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73239. */
  73240. explode(direction?: number): void;
  73241. }
  73242. }
  73243. declare module BABYLON {
  73244. /**
  73245. * Class used to help managing file picking and drag'n'drop
  73246. */
  73247. export class FilesInput {
  73248. /**
  73249. * List of files ready to be loaded
  73250. */
  73251. static get FilesToLoad(): {
  73252. [key: string]: File;
  73253. };
  73254. /**
  73255. * Callback called when a file is processed
  73256. */
  73257. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73258. private _engine;
  73259. private _currentScene;
  73260. private _sceneLoadedCallback;
  73261. private _progressCallback;
  73262. private _additionalRenderLoopLogicCallback;
  73263. private _textureLoadingCallback;
  73264. private _startingProcessingFilesCallback;
  73265. private _onReloadCallback;
  73266. private _errorCallback;
  73267. private _elementToMonitor;
  73268. private _sceneFileToLoad;
  73269. private _filesToLoad;
  73270. /**
  73271. * Creates a new FilesInput
  73272. * @param engine defines the rendering engine
  73273. * @param scene defines the hosting scene
  73274. * @param sceneLoadedCallback callback called when scene is loaded
  73275. * @param progressCallback callback called to track progress
  73276. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73277. * @param textureLoadingCallback callback called when a texture is loading
  73278. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73279. * @param onReloadCallback callback called when a reload is requested
  73280. * @param errorCallback callback call if an error occurs
  73281. */
  73282. 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>);
  73283. private _dragEnterHandler;
  73284. private _dragOverHandler;
  73285. private _dropHandler;
  73286. /**
  73287. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73288. * @param elementToMonitor defines the DOM element to track
  73289. */
  73290. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73291. /** Gets the current list of files to load */
  73292. get filesToLoad(): File[];
  73293. /**
  73294. * Release all associated resources
  73295. */
  73296. dispose(): void;
  73297. private renderFunction;
  73298. private drag;
  73299. private drop;
  73300. private _traverseFolder;
  73301. private _processFiles;
  73302. /**
  73303. * Load files from a drop event
  73304. * @param event defines the drop event to use as source
  73305. */
  73306. loadFiles(event: any): void;
  73307. private _processReload;
  73308. /**
  73309. * Reload the current scene from the loaded files
  73310. */
  73311. reload(): void;
  73312. }
  73313. }
  73314. declare module BABYLON {
  73315. /**
  73316. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73317. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73318. */
  73319. export class SceneOptimization {
  73320. /**
  73321. * Defines the priority of this optimization (0 by default which means first in the list)
  73322. */
  73323. priority: number;
  73324. /**
  73325. * Gets a string describing the action executed by the current optimization
  73326. * @returns description string
  73327. */
  73328. getDescription(): string;
  73329. /**
  73330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73331. * @param scene defines the current scene where to apply this optimization
  73332. * @param optimizer defines the current optimizer
  73333. * @returns true if everything that can be done was applied
  73334. */
  73335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73336. /**
  73337. * Creates the SceneOptimization object
  73338. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73339. * @param desc defines the description associated with the optimization
  73340. */
  73341. constructor(
  73342. /**
  73343. * Defines the priority of this optimization (0 by default which means first in the list)
  73344. */
  73345. priority?: number);
  73346. }
  73347. /**
  73348. * Defines an optimization used to reduce the size of render target textures
  73349. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73350. */
  73351. export class TextureOptimization extends SceneOptimization {
  73352. /**
  73353. * Defines the priority of this optimization (0 by default which means first in the list)
  73354. */
  73355. priority: number;
  73356. /**
  73357. * 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
  73358. */
  73359. maximumSize: number;
  73360. /**
  73361. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73362. */
  73363. step: number;
  73364. /**
  73365. * Gets a string describing the action executed by the current optimization
  73366. * @returns description string
  73367. */
  73368. getDescription(): string;
  73369. /**
  73370. * Creates the TextureOptimization object
  73371. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73372. * @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
  73373. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73374. */
  73375. constructor(
  73376. /**
  73377. * Defines the priority of this optimization (0 by default which means first in the list)
  73378. */
  73379. priority?: number,
  73380. /**
  73381. * 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
  73382. */
  73383. maximumSize?: number,
  73384. /**
  73385. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73386. */
  73387. step?: number);
  73388. /**
  73389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73390. * @param scene defines the current scene where to apply this optimization
  73391. * @param optimizer defines the current optimizer
  73392. * @returns true if everything that can be done was applied
  73393. */
  73394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73395. }
  73396. /**
  73397. * Defines an optimization used to increase or decrease the rendering resolution
  73398. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73399. */
  73400. export class HardwareScalingOptimization extends SceneOptimization {
  73401. /**
  73402. * Defines the priority of this optimization (0 by default which means first in the list)
  73403. */
  73404. priority: number;
  73405. /**
  73406. * Defines the maximum scale to use (2 by default)
  73407. */
  73408. maximumScale: number;
  73409. /**
  73410. * Defines the step to use between two passes (0.5 by default)
  73411. */
  73412. step: number;
  73413. private _currentScale;
  73414. private _directionOffset;
  73415. /**
  73416. * Gets a string describing the action executed by the current optimization
  73417. * @return description string
  73418. */
  73419. getDescription(): string;
  73420. /**
  73421. * Creates the HardwareScalingOptimization object
  73422. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73423. * @param maximumScale defines the maximum scale to use (2 by default)
  73424. * @param step defines the step to use between two passes (0.5 by default)
  73425. */
  73426. constructor(
  73427. /**
  73428. * Defines the priority of this optimization (0 by default which means first in the list)
  73429. */
  73430. priority?: number,
  73431. /**
  73432. * Defines the maximum scale to use (2 by default)
  73433. */
  73434. maximumScale?: number,
  73435. /**
  73436. * Defines the step to use between two passes (0.5 by default)
  73437. */
  73438. step?: number);
  73439. /**
  73440. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73441. * @param scene defines the current scene where to apply this optimization
  73442. * @param optimizer defines the current optimizer
  73443. * @returns true if everything that can be done was applied
  73444. */
  73445. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73446. }
  73447. /**
  73448. * Defines an optimization used to remove shadows
  73449. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73450. */
  73451. export class ShadowsOptimization extends SceneOptimization {
  73452. /**
  73453. * Gets a string describing the action executed by the current optimization
  73454. * @return description string
  73455. */
  73456. getDescription(): string;
  73457. /**
  73458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73459. * @param scene defines the current scene where to apply this optimization
  73460. * @param optimizer defines the current optimizer
  73461. * @returns true if everything that can be done was applied
  73462. */
  73463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73464. }
  73465. /**
  73466. * Defines an optimization used to turn post-processes off
  73467. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73468. */
  73469. export class PostProcessesOptimization extends SceneOptimization {
  73470. /**
  73471. * Gets a string describing the action executed by the current optimization
  73472. * @return description string
  73473. */
  73474. getDescription(): string;
  73475. /**
  73476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73477. * @param scene defines the current scene where to apply this optimization
  73478. * @param optimizer defines the current optimizer
  73479. * @returns true if everything that can be done was applied
  73480. */
  73481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73482. }
  73483. /**
  73484. * Defines an optimization used to turn lens flares off
  73485. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73486. */
  73487. export class LensFlaresOptimization extends SceneOptimization {
  73488. /**
  73489. * Gets a string describing the action executed by the current optimization
  73490. * @return description string
  73491. */
  73492. getDescription(): string;
  73493. /**
  73494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73495. * @param scene defines the current scene where to apply this optimization
  73496. * @param optimizer defines the current optimizer
  73497. * @returns true if everything that can be done was applied
  73498. */
  73499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73500. }
  73501. /**
  73502. * Defines an optimization based on user defined callback.
  73503. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73504. */
  73505. export class CustomOptimization extends SceneOptimization {
  73506. /**
  73507. * Callback called to apply the custom optimization.
  73508. */
  73509. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73510. /**
  73511. * Callback called to get custom description
  73512. */
  73513. onGetDescription: () => string;
  73514. /**
  73515. * Gets a string describing the action executed by the current optimization
  73516. * @returns description string
  73517. */
  73518. getDescription(): string;
  73519. /**
  73520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73521. * @param scene defines the current scene where to apply this optimization
  73522. * @param optimizer defines the current optimizer
  73523. * @returns true if everything that can be done was applied
  73524. */
  73525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73526. }
  73527. /**
  73528. * Defines an optimization used to turn particles off
  73529. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73530. */
  73531. export class ParticlesOptimization extends SceneOptimization {
  73532. /**
  73533. * Gets a string describing the action executed by the current optimization
  73534. * @return description string
  73535. */
  73536. getDescription(): string;
  73537. /**
  73538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73539. * @param scene defines the current scene where to apply this optimization
  73540. * @param optimizer defines the current optimizer
  73541. * @returns true if everything that can be done was applied
  73542. */
  73543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73544. }
  73545. /**
  73546. * Defines an optimization used to turn render targets off
  73547. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73548. */
  73549. export class RenderTargetsOptimization extends SceneOptimization {
  73550. /**
  73551. * Gets a string describing the action executed by the current optimization
  73552. * @return description string
  73553. */
  73554. getDescription(): string;
  73555. /**
  73556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73557. * @param scene defines the current scene where to apply this optimization
  73558. * @param optimizer defines the current optimizer
  73559. * @returns true if everything that can be done was applied
  73560. */
  73561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73562. }
  73563. /**
  73564. * Defines an optimization used to merge meshes with compatible materials
  73565. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73566. */
  73567. export class MergeMeshesOptimization extends SceneOptimization {
  73568. private static _UpdateSelectionTree;
  73569. /**
  73570. * Gets or sets a boolean which defines if optimization octree has to be updated
  73571. */
  73572. static get UpdateSelectionTree(): boolean;
  73573. /**
  73574. * Gets or sets a boolean which defines if optimization octree has to be updated
  73575. */
  73576. static set UpdateSelectionTree(value: boolean);
  73577. /**
  73578. * Gets a string describing the action executed by the current optimization
  73579. * @return description string
  73580. */
  73581. getDescription(): string;
  73582. private _canBeMerged;
  73583. /**
  73584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73585. * @param scene defines the current scene where to apply this optimization
  73586. * @param optimizer defines the current optimizer
  73587. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73588. * @returns true if everything that can be done was applied
  73589. */
  73590. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73591. }
  73592. /**
  73593. * Defines a list of options used by SceneOptimizer
  73594. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73595. */
  73596. export class SceneOptimizerOptions {
  73597. /**
  73598. * Defines the target frame rate to reach (60 by default)
  73599. */
  73600. targetFrameRate: number;
  73601. /**
  73602. * Defines the interval between two checkes (2000ms by default)
  73603. */
  73604. trackerDuration: number;
  73605. /**
  73606. * Gets the list of optimizations to apply
  73607. */
  73608. optimizations: SceneOptimization[];
  73609. /**
  73610. * Creates a new list of options used by SceneOptimizer
  73611. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73612. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73613. */
  73614. constructor(
  73615. /**
  73616. * Defines the target frame rate to reach (60 by default)
  73617. */
  73618. targetFrameRate?: number,
  73619. /**
  73620. * Defines the interval between two checkes (2000ms by default)
  73621. */
  73622. trackerDuration?: number);
  73623. /**
  73624. * Add a new optimization
  73625. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73626. * @returns the current SceneOptimizerOptions
  73627. */
  73628. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73629. /**
  73630. * Add a new custom optimization
  73631. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73632. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73633. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73634. * @returns the current SceneOptimizerOptions
  73635. */
  73636. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73637. /**
  73638. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73639. * @param targetFrameRate defines the target frame rate (60 by default)
  73640. * @returns a SceneOptimizerOptions object
  73641. */
  73642. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73643. /**
  73644. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73645. * @param targetFrameRate defines the target frame rate (60 by default)
  73646. * @returns a SceneOptimizerOptions object
  73647. */
  73648. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73649. /**
  73650. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73651. * @param targetFrameRate defines the target frame rate (60 by default)
  73652. * @returns a SceneOptimizerOptions object
  73653. */
  73654. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73655. }
  73656. /**
  73657. * Class used to run optimizations in order to reach a target frame rate
  73658. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73659. */
  73660. export class SceneOptimizer implements IDisposable {
  73661. private _isRunning;
  73662. private _options;
  73663. private _scene;
  73664. private _currentPriorityLevel;
  73665. private _targetFrameRate;
  73666. private _trackerDuration;
  73667. private _currentFrameRate;
  73668. private _sceneDisposeObserver;
  73669. private _improvementMode;
  73670. /**
  73671. * Defines an observable called when the optimizer reaches the target frame rate
  73672. */
  73673. onSuccessObservable: Observable<SceneOptimizer>;
  73674. /**
  73675. * Defines an observable called when the optimizer enables an optimization
  73676. */
  73677. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73678. /**
  73679. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73680. */
  73681. onFailureObservable: Observable<SceneOptimizer>;
  73682. /**
  73683. * Gets a boolean indicating if the optimizer is in improvement mode
  73684. */
  73685. get isInImprovementMode(): boolean;
  73686. /**
  73687. * Gets the current priority level (0 at start)
  73688. */
  73689. get currentPriorityLevel(): number;
  73690. /**
  73691. * Gets the current frame rate checked by the SceneOptimizer
  73692. */
  73693. get currentFrameRate(): number;
  73694. /**
  73695. * Gets or sets the current target frame rate (60 by default)
  73696. */
  73697. get targetFrameRate(): number;
  73698. /**
  73699. * Gets or sets the current target frame rate (60 by default)
  73700. */
  73701. set targetFrameRate(value: number);
  73702. /**
  73703. * Gets or sets the current interval between two checks (every 2000ms by default)
  73704. */
  73705. get trackerDuration(): number;
  73706. /**
  73707. * Gets or sets the current interval between two checks (every 2000ms by default)
  73708. */
  73709. set trackerDuration(value: number);
  73710. /**
  73711. * Gets the list of active optimizations
  73712. */
  73713. get optimizations(): SceneOptimization[];
  73714. /**
  73715. * Creates a new SceneOptimizer
  73716. * @param scene defines the scene to work on
  73717. * @param options defines the options to use with the SceneOptimizer
  73718. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73719. * @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)
  73720. */
  73721. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73722. /**
  73723. * Stops the current optimizer
  73724. */
  73725. stop(): void;
  73726. /**
  73727. * Reset the optimizer to initial step (current priority level = 0)
  73728. */
  73729. reset(): void;
  73730. /**
  73731. * Start the optimizer. By default it will try to reach a specific framerate
  73732. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73733. */
  73734. start(): void;
  73735. private _checkCurrentState;
  73736. /**
  73737. * Release all resources
  73738. */
  73739. dispose(): void;
  73740. /**
  73741. * Helper function to create a SceneOptimizer with one single line of code
  73742. * @param scene defines the scene to work on
  73743. * @param options defines the options to use with the SceneOptimizer
  73744. * @param onSuccess defines a callback to call on success
  73745. * @param onFailure defines a callback to call on failure
  73746. * @returns the new SceneOptimizer object
  73747. */
  73748. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /**
  73753. * Class used to serialize a scene into a string
  73754. */
  73755. export class SceneSerializer {
  73756. /**
  73757. * Clear cache used by a previous serialization
  73758. */
  73759. static ClearCache(): void;
  73760. /**
  73761. * Serialize a scene into a JSON compatible object
  73762. * @param scene defines the scene to serialize
  73763. * @returns a JSON compatible object
  73764. */
  73765. static Serialize(scene: Scene): any;
  73766. /**
  73767. * Serialize a mesh into a JSON compatible object
  73768. * @param toSerialize defines the mesh to serialize
  73769. * @param withParents defines if parents must be serialized as well
  73770. * @param withChildren defines if children must be serialized as well
  73771. * @returns a JSON compatible object
  73772. */
  73773. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73774. }
  73775. }
  73776. declare module BABYLON {
  73777. /**
  73778. * Class used to host texture specific utilities
  73779. */
  73780. export class TextureTools {
  73781. /**
  73782. * Uses the GPU to create a copy texture rescaled at a given size
  73783. * @param texture Texture to copy from
  73784. * @param width defines the desired width
  73785. * @param height defines the desired height
  73786. * @param useBilinearMode defines if bilinear mode has to be used
  73787. * @return the generated texture
  73788. */
  73789. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73790. }
  73791. }
  73792. declare module BABYLON {
  73793. /**
  73794. * This represents the different options available for the video capture.
  73795. */
  73796. export interface VideoRecorderOptions {
  73797. /** Defines the mime type of the video. */
  73798. mimeType: string;
  73799. /** Defines the FPS the video should be recorded at. */
  73800. fps: number;
  73801. /** Defines the chunk size for the recording data. */
  73802. recordChunckSize: number;
  73803. /** The audio tracks to attach to the recording. */
  73804. audioTracks?: MediaStreamTrack[];
  73805. }
  73806. /**
  73807. * This can help with recording videos from BabylonJS.
  73808. * This is based on the available WebRTC functionalities of the browser.
  73809. *
  73810. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73811. */
  73812. export class VideoRecorder {
  73813. private static readonly _defaultOptions;
  73814. /**
  73815. * Returns whether or not the VideoRecorder is available in your browser.
  73816. * @param engine Defines the Babylon Engine.
  73817. * @returns true if supported otherwise false.
  73818. */
  73819. static IsSupported(engine: Engine): boolean;
  73820. private readonly _options;
  73821. private _canvas;
  73822. private _mediaRecorder;
  73823. private _recordedChunks;
  73824. private _fileName;
  73825. private _resolve;
  73826. private _reject;
  73827. /**
  73828. * True when a recording is already in progress.
  73829. */
  73830. get isRecording(): boolean;
  73831. /**
  73832. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73833. * @param engine Defines the BabylonJS Engine you wish to record.
  73834. * @param options Defines options that can be used to customize the capture.
  73835. */
  73836. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73837. /**
  73838. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73839. */
  73840. stopRecording(): void;
  73841. /**
  73842. * Starts recording the canvas for a max duration specified in parameters.
  73843. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73844. * If null no automatic download will start and you can rely on the promise to get the data back.
  73845. * @param maxDuration Defines the maximum recording time in seconds.
  73846. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73847. * @return A promise callback at the end of the recording with the video data in Blob.
  73848. */
  73849. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73850. /**
  73851. * Releases internal resources used during the recording.
  73852. */
  73853. dispose(): void;
  73854. private _handleDataAvailable;
  73855. private _handleError;
  73856. private _handleStop;
  73857. }
  73858. }
  73859. declare module BABYLON {
  73860. /**
  73861. * Class containing a set of static utilities functions for screenshots
  73862. */
  73863. export class ScreenshotTools {
  73864. /**
  73865. * Captures a screenshot of the current rendering
  73866. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73867. * @param engine defines the rendering engine
  73868. * @param camera defines the source camera
  73869. * @param size This parameter can be set to a single number or to an object with the
  73870. * following (optional) properties: precision, width, height. If a single number is passed,
  73871. * it will be used for both width and height. If an object is passed, the screenshot size
  73872. * will be derived from the parameters. The precision property is a multiplier allowing
  73873. * rendering at a higher or lower resolution
  73874. * @param successCallback defines the callback receives a single parameter which contains the
  73875. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73876. * src parameter of an <img> to display it
  73877. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73878. * Check your browser for supported MIME types
  73879. */
  73880. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73881. /**
  73882. * Captures a screenshot of the current rendering
  73883. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73884. * @param engine defines the rendering engine
  73885. * @param camera defines the source camera
  73886. * @param size This parameter can be set to a single number or to an object with the
  73887. * following (optional) properties: precision, width, height. If a single number is passed,
  73888. * it will be used for both width and height. If an object is passed, the screenshot size
  73889. * will be derived from the parameters. The precision property is a multiplier allowing
  73890. * rendering at a higher or lower resolution
  73891. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73892. * Check your browser for supported MIME types
  73893. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73894. * to the src parameter of an <img> to display it
  73895. */
  73896. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73897. /**
  73898. * Generates an image screenshot from the specified camera.
  73899. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73900. * @param engine The engine to use for rendering
  73901. * @param camera The camera to use for rendering
  73902. * @param size This parameter can be set to a single number or to an object with the
  73903. * following (optional) properties: precision, width, height. If a single number is passed,
  73904. * it will be used for both width and height. If an object is passed, the screenshot size
  73905. * will be derived from the parameters. The precision property is a multiplier allowing
  73906. * rendering at a higher or lower resolution
  73907. * @param successCallback The callback receives a single parameter which contains the
  73908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73909. * src parameter of an <img> to display it
  73910. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73911. * Check your browser for supported MIME types
  73912. * @param samples Texture samples (default: 1)
  73913. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73914. * @param fileName A name for for the downloaded file.
  73915. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73916. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  73917. */
  73918. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  73919. /**
  73920. * Generates an image screenshot from the specified camera.
  73921. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73922. * @param engine The engine to use for rendering
  73923. * @param camera The camera to use for rendering
  73924. * @param size This parameter can be set to a single number or to an object with the
  73925. * following (optional) properties: precision, width, height. If a single number is passed,
  73926. * it will be used for both width and height. If an object is passed, the screenshot size
  73927. * will be derived from the parameters. The precision property is a multiplier allowing
  73928. * rendering at a higher or lower resolution
  73929. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73930. * Check your browser for supported MIME types
  73931. * @param samples Texture samples (default: 1)
  73932. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73933. * @param fileName A name for for the downloaded file.
  73934. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73935. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73936. * to the src parameter of an <img> to display it
  73937. */
  73938. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73939. /**
  73940. * Gets height and width for screenshot size
  73941. * @private
  73942. */
  73943. private static _getScreenshotSize;
  73944. }
  73945. }
  73946. declare module BABYLON {
  73947. /**
  73948. * Interface for a data buffer
  73949. */
  73950. export interface IDataBuffer {
  73951. /**
  73952. * Reads bytes from the data buffer.
  73953. * @param byteOffset The byte offset to read
  73954. * @param byteLength The byte length to read
  73955. * @returns A promise that resolves when the bytes are read
  73956. */
  73957. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73958. /**
  73959. * The byte length of the buffer.
  73960. */
  73961. readonly byteLength: number;
  73962. }
  73963. /**
  73964. * Utility class for reading from a data buffer
  73965. */
  73966. export class DataReader {
  73967. /**
  73968. * The data buffer associated with this data reader.
  73969. */
  73970. readonly buffer: IDataBuffer;
  73971. /**
  73972. * The current byte offset from the beginning of the data buffer.
  73973. */
  73974. byteOffset: number;
  73975. private _dataView;
  73976. private _dataByteOffset;
  73977. /**
  73978. * Constructor
  73979. * @param buffer The buffer to read
  73980. */
  73981. constructor(buffer: IDataBuffer);
  73982. /**
  73983. * Loads the given byte length.
  73984. * @param byteLength The byte length to load
  73985. * @returns A promise that resolves when the load is complete
  73986. */
  73987. loadAsync(byteLength: number): Promise<void>;
  73988. /**
  73989. * Read a unsigned 32-bit integer from the currently loaded data range.
  73990. * @returns The 32-bit integer read
  73991. */
  73992. readUint32(): number;
  73993. /**
  73994. * Read a byte array from the currently loaded data range.
  73995. * @param byteLength The byte length to read
  73996. * @returns The byte array read
  73997. */
  73998. readUint8Array(byteLength: number): Uint8Array;
  73999. /**
  74000. * Read a string from the currently loaded data range.
  74001. * @param byteLength The byte length to read
  74002. * @returns The string read
  74003. */
  74004. readString(byteLength: number): string;
  74005. /**
  74006. * Skips the given byte length the currently loaded data range.
  74007. * @param byteLength The byte length to skip
  74008. */
  74009. skipBytes(byteLength: number): void;
  74010. }
  74011. }
  74012. declare module BABYLON {
  74013. /**
  74014. * Class for storing data to local storage if available or in-memory storage otherwise
  74015. */
  74016. export class DataStorage {
  74017. private static _Storage;
  74018. private static _GetStorage;
  74019. /**
  74020. * Reads a string from the data storage
  74021. * @param key The key to read
  74022. * @param defaultValue The value if the key doesn't exist
  74023. * @returns The string value
  74024. */
  74025. static ReadString(key: string, defaultValue: string): string;
  74026. /**
  74027. * Writes a string to the data storage
  74028. * @param key The key to write
  74029. * @param value The value to write
  74030. */
  74031. static WriteString(key: string, value: string): void;
  74032. /**
  74033. * Reads a boolean from the data storage
  74034. * @param key The key to read
  74035. * @param defaultValue The value if the key doesn't exist
  74036. * @returns The boolean value
  74037. */
  74038. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74039. /**
  74040. * Writes a boolean to the data storage
  74041. * @param key The key to write
  74042. * @param value The value to write
  74043. */
  74044. static WriteBoolean(key: string, value: boolean): void;
  74045. /**
  74046. * Reads a number from the data storage
  74047. * @param key The key to read
  74048. * @param defaultValue The value if the key doesn't exist
  74049. * @returns The number value
  74050. */
  74051. static ReadNumber(key: string, defaultValue: number): number;
  74052. /**
  74053. * Writes a number to the data storage
  74054. * @param key The key to write
  74055. * @param value The value to write
  74056. */
  74057. static WriteNumber(key: string, value: number): void;
  74058. }
  74059. }
  74060. declare module BABYLON {
  74061. /**
  74062. * Class used to record delta files between 2 scene states
  74063. */
  74064. export class SceneRecorder {
  74065. private _trackedScene;
  74066. private _savedJSON;
  74067. /**
  74068. * Track a given scene. This means the current scene state will be considered the original state
  74069. * @param scene defines the scene to track
  74070. */
  74071. track(scene: Scene): void;
  74072. /**
  74073. * Get the delta between current state and original state
  74074. * @returns a string containing the delta
  74075. */
  74076. getDelta(): any;
  74077. private _compareArray;
  74078. private _compareObjects;
  74079. private _compareCollections;
  74080. private static GetShadowGeneratorById;
  74081. /**
  74082. * Apply a given delta to a given scene
  74083. * @param deltaJSON defines the JSON containing the delta
  74084. * @param scene defines the scene to apply the delta to
  74085. */
  74086. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74087. private static _ApplyPropertiesToEntity;
  74088. private static _ApplyDeltaForEntity;
  74089. }
  74090. }
  74091. declare module BABYLON {
  74092. /**
  74093. * An interface for all Hit test features
  74094. */
  74095. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74096. /**
  74097. * Triggered when new babylon (transformed) hit test results are available
  74098. */
  74099. onHitTestResultObservable: Observable<T[]>;
  74100. }
  74101. /**
  74102. * Options used for hit testing
  74103. */
  74104. export interface IWebXRLegacyHitTestOptions {
  74105. /**
  74106. * Only test when user interacted with the scene. Default - hit test every frame
  74107. */
  74108. testOnPointerDownOnly?: boolean;
  74109. /**
  74110. * The node to use to transform the local results to world coordinates
  74111. */
  74112. worldParentNode?: TransformNode;
  74113. }
  74114. /**
  74115. * Interface defining the babylon result of raycasting/hit-test
  74116. */
  74117. export interface IWebXRLegacyHitResult {
  74118. /**
  74119. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74120. */
  74121. transformationMatrix: Matrix;
  74122. /**
  74123. * The native hit test result
  74124. */
  74125. xrHitResult: XRHitResult | XRHitTestResult;
  74126. }
  74127. /**
  74128. * The currently-working hit-test module.
  74129. * Hit test (or Ray-casting) is used to interact with the real world.
  74130. * For further information read here - https://github.com/immersive-web/hit-test
  74131. */
  74132. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74133. /**
  74134. * options to use when constructing this feature
  74135. */
  74136. readonly options: IWebXRLegacyHitTestOptions;
  74137. private _direction;
  74138. private _mat;
  74139. private _onSelectEnabled;
  74140. private _origin;
  74141. /**
  74142. * The module's name
  74143. */
  74144. static readonly Name: string;
  74145. /**
  74146. * The (Babylon) version of this module.
  74147. * This is an integer representing the implementation version.
  74148. * This number does not correspond to the WebXR specs version
  74149. */
  74150. static readonly Version: number;
  74151. /**
  74152. * Populated with the last native XR Hit Results
  74153. */
  74154. lastNativeXRHitResults: XRHitResult[];
  74155. /**
  74156. * Triggered when new babylon (transformed) hit test results are available
  74157. */
  74158. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74159. /**
  74160. * Creates a new instance of the (legacy version) hit test feature
  74161. * @param _xrSessionManager an instance of WebXRSessionManager
  74162. * @param options options to use when constructing this feature
  74163. */
  74164. constructor(_xrSessionManager: WebXRSessionManager,
  74165. /**
  74166. * options to use when constructing this feature
  74167. */
  74168. options?: IWebXRLegacyHitTestOptions);
  74169. /**
  74170. * execute a hit test with an XR Ray
  74171. *
  74172. * @param xrSession a native xrSession that will execute this hit test
  74173. * @param xrRay the ray (position and direction) to use for ray-casting
  74174. * @param referenceSpace native XR reference space to use for the hit-test
  74175. * @param filter filter function that will filter the results
  74176. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74177. */
  74178. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74179. /**
  74180. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74181. * @param event the (select) event to use to select with
  74182. * @param referenceSpace the reference space to use for this hit test
  74183. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74184. */
  74185. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74186. /**
  74187. * attach this feature
  74188. * Will usually be called by the features manager
  74189. *
  74190. * @returns true if successful.
  74191. */
  74192. attach(): boolean;
  74193. /**
  74194. * detach this feature.
  74195. * Will usually be called by the features manager
  74196. *
  74197. * @returns true if successful.
  74198. */
  74199. detach(): boolean;
  74200. /**
  74201. * Dispose this feature and all of the resources attached
  74202. */
  74203. dispose(): void;
  74204. protected _onXRFrame(frame: XRFrame): void;
  74205. private _onHitTestResults;
  74206. private _onSelect;
  74207. }
  74208. }
  74209. declare module BABYLON {
  74210. /**
  74211. * Options used for hit testing (version 2)
  74212. */
  74213. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74214. /**
  74215. * Do not create a permanent hit test. Will usually be used when only
  74216. * transient inputs are needed.
  74217. */
  74218. disablePermanentHitTest?: boolean;
  74219. /**
  74220. * Enable transient (for example touch-based) hit test inspections
  74221. */
  74222. enableTransientHitTest?: boolean;
  74223. /**
  74224. * Offset ray for the permanent hit test
  74225. */
  74226. offsetRay?: Vector3;
  74227. /**
  74228. * Offset ray for the transient hit test
  74229. */
  74230. transientOffsetRay?: Vector3;
  74231. /**
  74232. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74233. */
  74234. useReferenceSpace?: boolean;
  74235. /**
  74236. * Override the default entity type(s) of the hit-test result
  74237. */
  74238. entityTypes?: XRHitTestTrackableType[];
  74239. }
  74240. /**
  74241. * Interface defining the babylon result of hit-test
  74242. */
  74243. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74244. /**
  74245. * The input source that generated this hit test (if transient)
  74246. */
  74247. inputSource?: XRInputSource;
  74248. /**
  74249. * Is this a transient hit test
  74250. */
  74251. isTransient?: boolean;
  74252. /**
  74253. * Position of the hit test result
  74254. */
  74255. position: Vector3;
  74256. /**
  74257. * Rotation of the hit test result
  74258. */
  74259. rotationQuaternion: Quaternion;
  74260. /**
  74261. * The native hit test result
  74262. */
  74263. xrHitResult: XRHitTestResult;
  74264. }
  74265. /**
  74266. * The currently-working hit-test module.
  74267. * Hit test (or Ray-casting) is used to interact with the real world.
  74268. * For further information read here - https://github.com/immersive-web/hit-test
  74269. *
  74270. * Tested on chrome (mobile) 80.
  74271. */
  74272. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74273. /**
  74274. * options to use when constructing this feature
  74275. */
  74276. readonly options: IWebXRHitTestOptions;
  74277. private _tmpMat;
  74278. private _tmpPos;
  74279. private _tmpQuat;
  74280. private _transientXrHitTestSource;
  74281. private _xrHitTestSource;
  74282. private initHitTestSource;
  74283. /**
  74284. * The module's name
  74285. */
  74286. static readonly Name: string;
  74287. /**
  74288. * The (Babylon) version of this module.
  74289. * This is an integer representing the implementation version.
  74290. * This number does not correspond to the WebXR specs version
  74291. */
  74292. static readonly Version: number;
  74293. /**
  74294. * When set to true, each hit test will have its own position/rotation objects
  74295. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74296. * the developers will clone them or copy them as they see fit.
  74297. */
  74298. autoCloneTransformation: boolean;
  74299. /**
  74300. * Triggered when new babylon (transformed) hit test results are available
  74301. */
  74302. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74303. /**
  74304. * Use this to temporarily pause hit test checks.
  74305. */
  74306. paused: boolean;
  74307. /**
  74308. * Creates a new instance of the hit test feature
  74309. * @param _xrSessionManager an instance of WebXRSessionManager
  74310. * @param options options to use when constructing this feature
  74311. */
  74312. constructor(_xrSessionManager: WebXRSessionManager,
  74313. /**
  74314. * options to use when constructing this feature
  74315. */
  74316. options?: IWebXRHitTestOptions);
  74317. /**
  74318. * attach this feature
  74319. * Will usually be called by the features manager
  74320. *
  74321. * @returns true if successful.
  74322. */
  74323. attach(): boolean;
  74324. /**
  74325. * detach this feature.
  74326. * Will usually be called by the features manager
  74327. *
  74328. * @returns true if successful.
  74329. */
  74330. detach(): boolean;
  74331. /**
  74332. * Dispose this feature and all of the resources attached
  74333. */
  74334. dispose(): void;
  74335. protected _onXRFrame(frame: XRFrame): void;
  74336. private _processWebXRHitTestResult;
  74337. }
  74338. }
  74339. declare module BABYLON {
  74340. /**
  74341. * Configuration options of the anchor system
  74342. */
  74343. export interface IWebXRAnchorSystemOptions {
  74344. /**
  74345. * a node that will be used to convert local to world coordinates
  74346. */
  74347. worldParentNode?: TransformNode;
  74348. /**
  74349. * If set to true a reference of the created anchors will be kept until the next session starts
  74350. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74351. */
  74352. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74353. }
  74354. /**
  74355. * A babylon container for an XR Anchor
  74356. */
  74357. export interface IWebXRAnchor {
  74358. /**
  74359. * A babylon-assigned ID for this anchor
  74360. */
  74361. id: number;
  74362. /**
  74363. * Transformation matrix to apply to an object attached to this anchor
  74364. */
  74365. transformationMatrix: Matrix;
  74366. /**
  74367. * The native anchor object
  74368. */
  74369. xrAnchor: XRAnchor;
  74370. /**
  74371. * if defined, this object will be constantly updated by the anchor's position and rotation
  74372. */
  74373. attachedNode?: TransformNode;
  74374. }
  74375. /**
  74376. * An implementation of the anchor system for WebXR.
  74377. * For further information see https://github.com/immersive-web/anchors/
  74378. */
  74379. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74380. private _options;
  74381. private _lastFrameDetected;
  74382. private _trackedAnchors;
  74383. private _referenceSpaceForFrameAnchors;
  74384. private _futureAnchors;
  74385. /**
  74386. * The module's name
  74387. */
  74388. static readonly Name: string;
  74389. /**
  74390. * The (Babylon) version of this module.
  74391. * This is an integer representing the implementation version.
  74392. * This number does not correspond to the WebXR specs version
  74393. */
  74394. static readonly Version: number;
  74395. /**
  74396. * Observers registered here will be executed when a new anchor was added to the session
  74397. */
  74398. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74399. /**
  74400. * Observers registered here will be executed when an anchor was removed from the session
  74401. */
  74402. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74403. /**
  74404. * Observers registered here will be executed when an existing anchor updates
  74405. * This can execute N times every frame
  74406. */
  74407. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74408. /**
  74409. * Set the reference space to use for anchor creation, when not using a hit test.
  74410. * Will default to the session's reference space if not defined
  74411. */
  74412. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74413. /**
  74414. * constructs a new anchor system
  74415. * @param _xrSessionManager an instance of WebXRSessionManager
  74416. * @param _options configuration object for this feature
  74417. */
  74418. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74419. private _tmpVector;
  74420. private _tmpQuaternion;
  74421. private _populateTmpTransformation;
  74422. /**
  74423. * Create a new anchor point using a hit test result at a specific point in the scene
  74424. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74425. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74426. *
  74427. * @param hitTestResult The hit test result to use for this anchor creation
  74428. * @param position an optional position offset for this anchor
  74429. * @param rotationQuaternion an optional rotation offset for this anchor
  74430. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74431. */
  74432. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74433. /**
  74434. * Add a new anchor at a specific position and rotation
  74435. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74436. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74437. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74438. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74439. *
  74440. * @param position the position in which to add an anchor
  74441. * @param rotationQuaternion an optional rotation for the anchor transformation
  74442. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74443. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74444. */
  74445. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74446. /**
  74447. * detach this feature.
  74448. * Will usually be called by the features manager
  74449. *
  74450. * @returns true if successful.
  74451. */
  74452. detach(): boolean;
  74453. /**
  74454. * Dispose this feature and all of the resources attached
  74455. */
  74456. dispose(): void;
  74457. protected _onXRFrame(frame: XRFrame): void;
  74458. /**
  74459. * avoiding using Array.find for global support.
  74460. * @param xrAnchor the plane to find in the array
  74461. */
  74462. private _findIndexInAnchorArray;
  74463. private _updateAnchorWithXRFrame;
  74464. private _createAnchorAtTransformation;
  74465. }
  74466. }
  74467. declare module BABYLON {
  74468. /**
  74469. * Options used in the plane detector module
  74470. */
  74471. export interface IWebXRPlaneDetectorOptions {
  74472. /**
  74473. * The node to use to transform the local results to world coordinates
  74474. */
  74475. worldParentNode?: TransformNode;
  74476. /**
  74477. * If set to true a reference of the created planes will be kept until the next session starts
  74478. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74479. */
  74480. doNotRemovePlanesOnSessionEnded?: boolean;
  74481. }
  74482. /**
  74483. * A babylon interface for a WebXR plane.
  74484. * A Plane is actually a polygon, built from N points in space
  74485. *
  74486. * Supported in chrome 79, not supported in canary 81 ATM
  74487. */
  74488. export interface IWebXRPlane {
  74489. /**
  74490. * a babylon-assigned ID for this polygon
  74491. */
  74492. id: number;
  74493. /**
  74494. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74495. */
  74496. polygonDefinition: Array<Vector3>;
  74497. /**
  74498. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74499. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74500. */
  74501. transformationMatrix: Matrix;
  74502. /**
  74503. * the native xr-plane object
  74504. */
  74505. xrPlane: XRPlane;
  74506. }
  74507. /**
  74508. * The plane detector is used to detect planes in the real world when in AR
  74509. * For more information see https://github.com/immersive-web/real-world-geometry/
  74510. */
  74511. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74512. private _options;
  74513. private _detectedPlanes;
  74514. private _enabled;
  74515. private _lastFrameDetected;
  74516. /**
  74517. * The module's name
  74518. */
  74519. static readonly Name: string;
  74520. /**
  74521. * The (Babylon) version of this module.
  74522. * This is an integer representing the implementation version.
  74523. * This number does not correspond to the WebXR specs version
  74524. */
  74525. static readonly Version: number;
  74526. /**
  74527. * Observers registered here will be executed when a new plane was added to the session
  74528. */
  74529. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74530. /**
  74531. * Observers registered here will be executed when a plane is no longer detected in the session
  74532. */
  74533. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74534. /**
  74535. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74536. * This can execute N times every frame
  74537. */
  74538. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74539. /**
  74540. * construct a new Plane Detector
  74541. * @param _xrSessionManager an instance of xr Session manager
  74542. * @param _options configuration to use when constructing this feature
  74543. */
  74544. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74545. /**
  74546. * detach this feature.
  74547. * Will usually be called by the features manager
  74548. *
  74549. * @returns true if successful.
  74550. */
  74551. detach(): boolean;
  74552. /**
  74553. * Dispose this feature and all of the resources attached
  74554. */
  74555. dispose(): void;
  74556. protected _onXRFrame(frame: XRFrame): void;
  74557. private _init;
  74558. private _updatePlaneWithXRPlane;
  74559. /**
  74560. * avoiding using Array.find for global support.
  74561. * @param xrPlane the plane to find in the array
  74562. */
  74563. private findIndexInPlaneArray;
  74564. }
  74565. }
  74566. declare module BABYLON {
  74567. /**
  74568. * Options interface for the background remover plugin
  74569. */
  74570. export interface IWebXRBackgroundRemoverOptions {
  74571. /**
  74572. * Further background meshes to disable when entering AR
  74573. */
  74574. backgroundMeshes?: AbstractMesh[];
  74575. /**
  74576. * flags to configure the removal of the environment helper.
  74577. * If not set, the entire background will be removed. If set, flags should be set as well.
  74578. */
  74579. environmentHelperRemovalFlags?: {
  74580. /**
  74581. * Should the skybox be removed (default false)
  74582. */
  74583. skyBox?: boolean;
  74584. /**
  74585. * Should the ground be removed (default false)
  74586. */
  74587. ground?: boolean;
  74588. };
  74589. /**
  74590. * don't disable the environment helper
  74591. */
  74592. ignoreEnvironmentHelper?: boolean;
  74593. }
  74594. /**
  74595. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74596. */
  74597. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74598. /**
  74599. * read-only options to be used in this module
  74600. */
  74601. readonly options: IWebXRBackgroundRemoverOptions;
  74602. /**
  74603. * The module's name
  74604. */
  74605. static readonly Name: string;
  74606. /**
  74607. * The (Babylon) version of this module.
  74608. * This is an integer representing the implementation version.
  74609. * This number does not correspond to the WebXR specs version
  74610. */
  74611. static readonly Version: number;
  74612. /**
  74613. * registered observers will be triggered when the background state changes
  74614. */
  74615. onBackgroundStateChangedObservable: Observable<boolean>;
  74616. /**
  74617. * constructs a new background remover module
  74618. * @param _xrSessionManager the session manager for this module
  74619. * @param options read-only options to be used in this module
  74620. */
  74621. constructor(_xrSessionManager: WebXRSessionManager,
  74622. /**
  74623. * read-only options to be used in this module
  74624. */
  74625. options?: IWebXRBackgroundRemoverOptions);
  74626. /**
  74627. * attach this feature
  74628. * Will usually be called by the features manager
  74629. *
  74630. * @returns true if successful.
  74631. */
  74632. attach(): boolean;
  74633. /**
  74634. * detach this feature.
  74635. * Will usually be called by the features manager
  74636. *
  74637. * @returns true if successful.
  74638. */
  74639. detach(): boolean;
  74640. /**
  74641. * Dispose this feature and all of the resources attached
  74642. */
  74643. dispose(): void;
  74644. protected _onXRFrame(_xrFrame: XRFrame): void;
  74645. private _setBackgroundState;
  74646. }
  74647. }
  74648. declare module BABYLON {
  74649. /**
  74650. * Options for the controller physics feature
  74651. */
  74652. export class IWebXRControllerPhysicsOptions {
  74653. /**
  74654. * Should the headset get its own impostor
  74655. */
  74656. enableHeadsetImpostor?: boolean;
  74657. /**
  74658. * Optional parameters for the headset impostor
  74659. */
  74660. headsetImpostorParams?: {
  74661. /**
  74662. * The type of impostor to create. Default is sphere
  74663. */
  74664. impostorType: number;
  74665. /**
  74666. * the size of the impostor. Defaults to 10cm
  74667. */
  74668. impostorSize?: number | {
  74669. width: number;
  74670. height: number;
  74671. depth: number;
  74672. };
  74673. /**
  74674. * Friction definitions
  74675. */
  74676. friction?: number;
  74677. /**
  74678. * Restitution
  74679. */
  74680. restitution?: number;
  74681. };
  74682. /**
  74683. * The physics properties of the future impostors
  74684. */
  74685. physicsProperties?: {
  74686. /**
  74687. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74688. * Note that this requires a physics engine that supports mesh impostors!
  74689. */
  74690. useControllerMesh?: boolean;
  74691. /**
  74692. * The type of impostor to create. Default is sphere
  74693. */
  74694. impostorType?: number;
  74695. /**
  74696. * the size of the impostor. Defaults to 10cm
  74697. */
  74698. impostorSize?: number | {
  74699. width: number;
  74700. height: number;
  74701. depth: number;
  74702. };
  74703. /**
  74704. * Friction definitions
  74705. */
  74706. friction?: number;
  74707. /**
  74708. * Restitution
  74709. */
  74710. restitution?: number;
  74711. };
  74712. /**
  74713. * the xr input to use with this pointer selection
  74714. */
  74715. xrInput: WebXRInput;
  74716. }
  74717. /**
  74718. * Add physics impostor to your webxr controllers,
  74719. * including naive calculation of their linear and angular velocity
  74720. */
  74721. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74722. private readonly _options;
  74723. private _attachController;
  74724. private _controllers;
  74725. private _debugMode;
  74726. private _delta;
  74727. private _headsetImpostor?;
  74728. private _headsetMesh?;
  74729. private _lastTimestamp;
  74730. private _tmpQuaternion;
  74731. private _tmpVector;
  74732. /**
  74733. * The module's name
  74734. */
  74735. static readonly Name: string;
  74736. /**
  74737. * The (Babylon) version of this module.
  74738. * This is an integer representing the implementation version.
  74739. * This number does not correspond to the webxr specs version
  74740. */
  74741. static readonly Version: number;
  74742. /**
  74743. * Construct a new Controller Physics Feature
  74744. * @param _xrSessionManager the corresponding xr session manager
  74745. * @param _options options to create this feature with
  74746. */
  74747. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74748. /**
  74749. * @hidden
  74750. * enable debugging - will show console outputs and the impostor mesh
  74751. */
  74752. _enablePhysicsDebug(): void;
  74753. /**
  74754. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74755. * @param xrController the controller to add
  74756. */
  74757. addController(xrController: WebXRInputSource): void;
  74758. /**
  74759. * attach this feature
  74760. * Will usually be called by the features manager
  74761. *
  74762. * @returns true if successful.
  74763. */
  74764. attach(): boolean;
  74765. /**
  74766. * detach this feature.
  74767. * Will usually be called by the features manager
  74768. *
  74769. * @returns true if successful.
  74770. */
  74771. detach(): boolean;
  74772. /**
  74773. * Get the headset impostor, if enabled
  74774. * @returns the impostor
  74775. */
  74776. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74777. /**
  74778. * Get the physics impostor of a specific controller.
  74779. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74780. * @param controller the controller or the controller id of which to get the impostor
  74781. * @returns the impostor or null
  74782. */
  74783. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74784. /**
  74785. * Update the physics properties provided in the constructor
  74786. * @param newProperties the new properties object
  74787. */
  74788. setPhysicsProperties(newProperties: {
  74789. impostorType?: number;
  74790. impostorSize?: number | {
  74791. width: number;
  74792. height: number;
  74793. depth: number;
  74794. };
  74795. friction?: number;
  74796. restitution?: number;
  74797. }): void;
  74798. protected _onXRFrame(_xrFrame: any): void;
  74799. private _detachController;
  74800. }
  74801. }
  74802. declare module BABYLON {
  74803. /**
  74804. * A babylon interface for a "WebXR" feature point.
  74805. * Represents the position and confidence value of a given feature point.
  74806. */
  74807. export interface IWebXRFeaturePoint {
  74808. /**
  74809. * Represents the position of the feature point in world space.
  74810. */
  74811. position: Vector3;
  74812. /**
  74813. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  74814. */
  74815. confidenceValue: number;
  74816. }
  74817. /**
  74818. * The feature point system is used to detect feature points from real world geometry.
  74819. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  74820. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  74821. */
  74822. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  74823. private _enabled;
  74824. private _featurePointCloud;
  74825. /**
  74826. * The module's name
  74827. */
  74828. static readonly Name: string;
  74829. /**
  74830. * The (Babylon) version of this module.
  74831. * This is an integer representing the implementation version.
  74832. * This number does not correspond to the WebXR specs version
  74833. */
  74834. static readonly Version: number;
  74835. /**
  74836. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  74837. * Will notify the observers about which feature points have been added.
  74838. */
  74839. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  74840. /**
  74841. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  74842. * Will notify the observers about which feature points have been updated.
  74843. */
  74844. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  74845. /**
  74846. * The current feature point cloud maintained across frames.
  74847. */
  74848. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  74849. /**
  74850. * construct the feature point system
  74851. * @param _xrSessionManager an instance of xr Session manager
  74852. */
  74853. constructor(_xrSessionManager: WebXRSessionManager);
  74854. /**
  74855. * Detach this feature.
  74856. * Will usually be called by the features manager
  74857. *
  74858. * @returns true if successful.
  74859. */
  74860. detach(): boolean;
  74861. /**
  74862. * Dispose this feature and all of the resources attached
  74863. */
  74864. dispose(): void;
  74865. /**
  74866. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  74867. */
  74868. protected _onXRFrame(frame: XRFrame): void;
  74869. /**
  74870. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  74871. */
  74872. private _init;
  74873. }
  74874. }
  74875. declare module BABYLON {
  74876. /**
  74877. * Configuration interface for the hand tracking feature
  74878. */
  74879. export interface IWebXRHandTrackingOptions {
  74880. /**
  74881. * The xrInput that will be used as source for new hands
  74882. */
  74883. xrInput: WebXRInput;
  74884. /**
  74885. * Configuration object for the joint meshes
  74886. */
  74887. jointMeshes?: {
  74888. /**
  74889. * Should the meshes created be invisible (defaults to false)
  74890. */
  74891. invisible?: boolean;
  74892. /**
  74893. * A source mesh to be used to create instances. Defaults to a sphere.
  74894. * This mesh will be the source for all other (25) meshes.
  74895. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  74896. */
  74897. sourceMesh?: Mesh;
  74898. /**
  74899. * Should the source mesh stay visible. Defaults to false
  74900. */
  74901. keepOriginalVisible?: boolean;
  74902. /**
  74903. * Scale factor for all instances (defaults to 2)
  74904. */
  74905. scaleFactor?: number;
  74906. /**
  74907. * Should each instance have its own physics impostor
  74908. */
  74909. enablePhysics?: boolean;
  74910. /**
  74911. * If enabled, override default physics properties
  74912. */
  74913. physicsProps?: {
  74914. friction?: number;
  74915. restitution?: number;
  74916. impostorType?: number;
  74917. };
  74918. /**
  74919. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  74920. */
  74921. handMesh?: AbstractMesh;
  74922. };
  74923. }
  74924. /**
  74925. * Parts of the hands divided to writs and finger names
  74926. */
  74927. export const enum HandPart {
  74928. /**
  74929. * HandPart - Wrist
  74930. */
  74931. WRIST = "wrist",
  74932. /**
  74933. * HandPart - The THumb
  74934. */
  74935. THUMB = "thumb",
  74936. /**
  74937. * HandPart - Index finger
  74938. */
  74939. INDEX = "index",
  74940. /**
  74941. * HandPart - Middle finger
  74942. */
  74943. MIDDLE = "middle",
  74944. /**
  74945. * HandPart - Ring finger
  74946. */
  74947. RING = "ring",
  74948. /**
  74949. * HandPart - Little finger
  74950. */
  74951. LITTLE = "little"
  74952. }
  74953. /**
  74954. * Representing a single hand (with its corresponding native XRHand object)
  74955. */
  74956. export class WebXRHand implements IDisposable {
  74957. /** the controller to which the hand correlates */
  74958. readonly xrController: WebXRInputSource;
  74959. /** the meshes to be used to track the hand joints */
  74960. readonly trackedMeshes: AbstractMesh[];
  74961. /**
  74962. * Hand-parts definition (key is HandPart)
  74963. */
  74964. static HandPartsDefinition: {
  74965. [key: string]: number[];
  74966. };
  74967. /**
  74968. * Populate the HandPartsDefinition object.
  74969. * This is called as a side effect since certain browsers don't have XRHand defined.
  74970. */
  74971. static _PopulateHandPartsDefinition(): void;
  74972. /**
  74973. * Construct a new hand object
  74974. * @param xrController the controller to which the hand correlates
  74975. * @param trackedMeshes the meshes to be used to track the hand joints
  74976. */
  74977. constructor(
  74978. /** the controller to which the hand correlates */
  74979. xrController: WebXRInputSource,
  74980. /** the meshes to be used to track the hand joints */
  74981. trackedMeshes: AbstractMesh[]);
  74982. /**
  74983. * Update this hand from the latest xr frame
  74984. * @param xrFrame xrFrame to update from
  74985. * @param referenceSpace The current viewer reference space
  74986. * @param scaleFactor optional scale factor for the meshes
  74987. */
  74988. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  74989. /**
  74990. * Get meshes of part of the hand
  74991. * @param part the part of hand to get
  74992. * @returns An array of meshes that correlate to the hand part requested
  74993. */
  74994. getHandPartMeshes(part: HandPart): AbstractMesh[];
  74995. /**
  74996. * Dispose this Hand object
  74997. */
  74998. dispose(): void;
  74999. }
  75000. /**
  75001. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75002. */
  75003. export class WebXRHandTracking extends WebXRAbstractFeature {
  75004. /**
  75005. * options to use when constructing this feature
  75006. */
  75007. readonly options: IWebXRHandTrackingOptions;
  75008. private static _idCounter;
  75009. /**
  75010. * The module's name
  75011. */
  75012. static readonly Name: string;
  75013. /**
  75014. * The (Babylon) version of this module.
  75015. * This is an integer representing the implementation version.
  75016. * This number does not correspond to the WebXR specs version
  75017. */
  75018. static readonly Version: number;
  75019. /**
  75020. * This observable will notify registered observers when a new hand object was added and initialized
  75021. */
  75022. onHandAddedObservable: Observable<WebXRHand>;
  75023. /**
  75024. * This observable will notify its observers right before the hand object is disposed
  75025. */
  75026. onHandRemovedObservable: Observable<WebXRHand>;
  75027. private _hands;
  75028. /**
  75029. * Creates a new instance of the hit test feature
  75030. * @param _xrSessionManager an instance of WebXRSessionManager
  75031. * @param options options to use when constructing this feature
  75032. */
  75033. constructor(_xrSessionManager: WebXRSessionManager,
  75034. /**
  75035. * options to use when constructing this feature
  75036. */
  75037. options: IWebXRHandTrackingOptions);
  75038. /**
  75039. * Check if the needed objects are defined.
  75040. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75041. */
  75042. isCompatible(): boolean;
  75043. /**
  75044. * attach this feature
  75045. * Will usually be called by the features manager
  75046. *
  75047. * @returns true if successful.
  75048. */
  75049. attach(): boolean;
  75050. /**
  75051. * detach this feature.
  75052. * Will usually be called by the features manager
  75053. *
  75054. * @returns true if successful.
  75055. */
  75056. detach(): boolean;
  75057. /**
  75058. * Dispose this feature and all of the resources attached
  75059. */
  75060. dispose(): void;
  75061. /**
  75062. * Get the hand object according to the controller id
  75063. * @param controllerId the controller id to which we want to get the hand
  75064. * @returns null if not found or the WebXRHand object if found
  75065. */
  75066. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75067. /**
  75068. * Get a hand object according to the requested handedness
  75069. * @param handedness the handedness to request
  75070. * @returns null if not found or the WebXRHand object if found
  75071. */
  75072. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75073. protected _onXRFrame(_xrFrame: XRFrame): void;
  75074. private _attachHand;
  75075. private _detachHand;
  75076. }
  75077. }
  75078. declare module BABYLON {
  75079. /**
  75080. * The motion controller class for all microsoft mixed reality controllers
  75081. */
  75082. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75083. protected readonly _mapping: {
  75084. defaultButton: {
  75085. valueNodeName: string;
  75086. unpressedNodeName: string;
  75087. pressedNodeName: string;
  75088. };
  75089. defaultAxis: {
  75090. valueNodeName: string;
  75091. minNodeName: string;
  75092. maxNodeName: string;
  75093. };
  75094. buttons: {
  75095. "xr-standard-trigger": {
  75096. rootNodeName: string;
  75097. componentProperty: string;
  75098. states: string[];
  75099. };
  75100. "xr-standard-squeeze": {
  75101. rootNodeName: string;
  75102. componentProperty: string;
  75103. states: string[];
  75104. };
  75105. "xr-standard-touchpad": {
  75106. rootNodeName: string;
  75107. labelAnchorNodeName: string;
  75108. touchPointNodeName: string;
  75109. };
  75110. "xr-standard-thumbstick": {
  75111. rootNodeName: string;
  75112. componentProperty: string;
  75113. states: string[];
  75114. };
  75115. };
  75116. axes: {
  75117. "xr-standard-touchpad": {
  75118. "x-axis": {
  75119. rootNodeName: string;
  75120. };
  75121. "y-axis": {
  75122. rootNodeName: string;
  75123. };
  75124. };
  75125. "xr-standard-thumbstick": {
  75126. "x-axis": {
  75127. rootNodeName: string;
  75128. };
  75129. "y-axis": {
  75130. rootNodeName: string;
  75131. };
  75132. };
  75133. };
  75134. };
  75135. /**
  75136. * The base url used to load the left and right controller models
  75137. */
  75138. static MODEL_BASE_URL: string;
  75139. /**
  75140. * The name of the left controller model file
  75141. */
  75142. static MODEL_LEFT_FILENAME: string;
  75143. /**
  75144. * The name of the right controller model file
  75145. */
  75146. static MODEL_RIGHT_FILENAME: string;
  75147. profileId: string;
  75148. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75149. protected _getFilenameAndPath(): {
  75150. filename: string;
  75151. path: string;
  75152. };
  75153. protected _getModelLoadingConstraints(): boolean;
  75154. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75155. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75156. protected _updateModel(): void;
  75157. }
  75158. }
  75159. declare module BABYLON {
  75160. /**
  75161. * The motion controller class for oculus touch (quest, rift).
  75162. * This class supports legacy mapping as well the standard xr mapping
  75163. */
  75164. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75165. private _forceLegacyControllers;
  75166. private _modelRootNode;
  75167. /**
  75168. * The base url used to load the left and right controller models
  75169. */
  75170. static MODEL_BASE_URL: string;
  75171. /**
  75172. * The name of the left controller model file
  75173. */
  75174. static MODEL_LEFT_FILENAME: string;
  75175. /**
  75176. * The name of the right controller model file
  75177. */
  75178. static MODEL_RIGHT_FILENAME: string;
  75179. /**
  75180. * Base Url for the Quest controller model.
  75181. */
  75182. static QUEST_MODEL_BASE_URL: string;
  75183. profileId: string;
  75184. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75185. protected _getFilenameAndPath(): {
  75186. filename: string;
  75187. path: string;
  75188. };
  75189. protected _getModelLoadingConstraints(): boolean;
  75190. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75191. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75192. protected _updateModel(): void;
  75193. /**
  75194. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75195. * between the touch and touch 2.
  75196. */
  75197. private _isQuest;
  75198. }
  75199. }
  75200. declare module BABYLON {
  75201. /**
  75202. * The motion controller class for the standard HTC-Vive controllers
  75203. */
  75204. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75205. private _modelRootNode;
  75206. /**
  75207. * The base url used to load the left and right controller models
  75208. */
  75209. static MODEL_BASE_URL: string;
  75210. /**
  75211. * File name for the controller model.
  75212. */
  75213. static MODEL_FILENAME: string;
  75214. profileId: string;
  75215. /**
  75216. * Create a new Vive motion controller object
  75217. * @param scene the scene to use to create this controller
  75218. * @param gamepadObject the corresponding gamepad object
  75219. * @param handedness the handedness of the controller
  75220. */
  75221. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75222. protected _getFilenameAndPath(): {
  75223. filename: string;
  75224. path: string;
  75225. };
  75226. protected _getModelLoadingConstraints(): boolean;
  75227. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75228. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75229. protected _updateModel(): void;
  75230. }
  75231. }
  75232. declare module BABYLON {
  75233. /**
  75234. * A cursor which tracks a point on a path
  75235. */
  75236. export class PathCursor {
  75237. private path;
  75238. /**
  75239. * Stores path cursor callbacks for when an onchange event is triggered
  75240. */
  75241. private _onchange;
  75242. /**
  75243. * The value of the path cursor
  75244. */
  75245. value: number;
  75246. /**
  75247. * The animation array of the path cursor
  75248. */
  75249. animations: Animation[];
  75250. /**
  75251. * Initializes the path cursor
  75252. * @param path The path to track
  75253. */
  75254. constructor(path: Path2);
  75255. /**
  75256. * Gets the cursor point on the path
  75257. * @returns A point on the path cursor at the cursor location
  75258. */
  75259. getPoint(): Vector3;
  75260. /**
  75261. * Moves the cursor ahead by the step amount
  75262. * @param step The amount to move the cursor forward
  75263. * @returns This path cursor
  75264. */
  75265. moveAhead(step?: number): PathCursor;
  75266. /**
  75267. * Moves the cursor behind by the step amount
  75268. * @param step The amount to move the cursor back
  75269. * @returns This path cursor
  75270. */
  75271. moveBack(step?: number): PathCursor;
  75272. /**
  75273. * Moves the cursor by the step amount
  75274. * If the step amount is greater than one, an exception is thrown
  75275. * @param step The amount to move the cursor
  75276. * @returns This path cursor
  75277. */
  75278. move(step: number): PathCursor;
  75279. /**
  75280. * Ensures that the value is limited between zero and one
  75281. * @returns This path cursor
  75282. */
  75283. private ensureLimits;
  75284. /**
  75285. * Runs onchange callbacks on change (used by the animation engine)
  75286. * @returns This path cursor
  75287. */
  75288. private raiseOnChange;
  75289. /**
  75290. * Executes a function on change
  75291. * @param f A path cursor onchange callback
  75292. * @returns This path cursor
  75293. */
  75294. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75295. }
  75296. }
  75297. declare module BABYLON {
  75298. /** @hidden */
  75299. export var blurPixelShader: {
  75300. name: string;
  75301. shader: string;
  75302. };
  75303. }
  75304. declare module BABYLON {
  75305. /** @hidden */
  75306. export var pointCloudVertexDeclaration: {
  75307. name: string;
  75308. shader: string;
  75309. };
  75310. }
  75311. // Mixins
  75312. interface Window {
  75313. mozIndexedDB: IDBFactory;
  75314. webkitIndexedDB: IDBFactory;
  75315. msIndexedDB: IDBFactory;
  75316. webkitURL: typeof URL;
  75317. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75318. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75319. WebGLRenderingContext: WebGLRenderingContext;
  75320. MSGesture: MSGesture;
  75321. CANNON: any;
  75322. AudioContext: AudioContext;
  75323. webkitAudioContext: AudioContext;
  75324. PointerEvent: any;
  75325. Math: Math;
  75326. Uint8Array: Uint8ArrayConstructor;
  75327. Float32Array: Float32ArrayConstructor;
  75328. mozURL: typeof URL;
  75329. msURL: typeof URL;
  75330. VRFrameData: any; // WebVR, from specs 1.1
  75331. DracoDecoderModule: any;
  75332. setImmediate(handler: (...args: any[]) => void): number;
  75333. }
  75334. interface HTMLCanvasElement {
  75335. requestPointerLock(): void;
  75336. msRequestPointerLock?(): void;
  75337. mozRequestPointerLock?(): void;
  75338. webkitRequestPointerLock?(): void;
  75339. /** Track wether a record is in progress */
  75340. isRecording: boolean;
  75341. /** Capture Stream method defined by some browsers */
  75342. captureStream(fps?: number): MediaStream;
  75343. }
  75344. interface CanvasRenderingContext2D {
  75345. msImageSmoothingEnabled: boolean;
  75346. }
  75347. interface MouseEvent {
  75348. mozMovementX: number;
  75349. mozMovementY: number;
  75350. webkitMovementX: number;
  75351. webkitMovementY: number;
  75352. msMovementX: number;
  75353. msMovementY: number;
  75354. }
  75355. interface Navigator {
  75356. mozGetVRDevices: (any: any) => any;
  75357. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75358. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75359. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75360. webkitGetGamepads(): Gamepad[];
  75361. msGetGamepads(): Gamepad[];
  75362. webkitGamepads(): Gamepad[];
  75363. }
  75364. interface HTMLVideoElement {
  75365. mozSrcObject: any;
  75366. }
  75367. interface Math {
  75368. fround(x: number): number;
  75369. imul(a: number, b: number): number;
  75370. }
  75371. interface WebGLRenderingContext {
  75372. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75373. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75374. vertexAttribDivisor(index: number, divisor: number): void;
  75375. createVertexArray(): any;
  75376. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75377. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75378. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75379. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75380. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75381. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75382. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75383. // Queries
  75384. createQuery(): WebGLQuery;
  75385. deleteQuery(query: WebGLQuery): void;
  75386. beginQuery(target: number, query: WebGLQuery): void;
  75387. endQuery(target: number): void;
  75388. getQueryParameter(query: WebGLQuery, pname: number): any;
  75389. getQuery(target: number, pname: number): any;
  75390. MAX_SAMPLES: number;
  75391. RGBA8: number;
  75392. READ_FRAMEBUFFER: number;
  75393. DRAW_FRAMEBUFFER: number;
  75394. UNIFORM_BUFFER: number;
  75395. HALF_FLOAT_OES: number;
  75396. RGBA16F: number;
  75397. RGBA32F: number;
  75398. R32F: number;
  75399. RG32F: number;
  75400. RGB32F: number;
  75401. R16F: number;
  75402. RG16F: number;
  75403. RGB16F: number;
  75404. RED: number;
  75405. RG: number;
  75406. R8: number;
  75407. RG8: number;
  75408. UNSIGNED_INT_24_8: number;
  75409. DEPTH24_STENCIL8: number;
  75410. MIN: number;
  75411. MAX: number;
  75412. /* Multiple Render Targets */
  75413. drawBuffers(buffers: number[]): void;
  75414. readBuffer(src: number): void;
  75415. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75416. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75417. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75418. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75419. // Occlusion Query
  75420. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75421. ANY_SAMPLES_PASSED: number;
  75422. QUERY_RESULT_AVAILABLE: number;
  75423. QUERY_RESULT: number;
  75424. }
  75425. interface WebGLProgram {
  75426. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75427. }
  75428. interface EXT_disjoint_timer_query {
  75429. QUERY_COUNTER_BITS_EXT: number;
  75430. TIME_ELAPSED_EXT: number;
  75431. TIMESTAMP_EXT: number;
  75432. GPU_DISJOINT_EXT: number;
  75433. QUERY_RESULT_EXT: number;
  75434. QUERY_RESULT_AVAILABLE_EXT: number;
  75435. queryCounterEXT(query: WebGLQuery, target: number): void;
  75436. createQueryEXT(): WebGLQuery;
  75437. beginQueryEXT(target: number, query: WebGLQuery): void;
  75438. endQueryEXT(target: number): void;
  75439. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75440. deleteQueryEXT(query: WebGLQuery): void;
  75441. }
  75442. interface WebGLUniformLocation {
  75443. _currentState: any;
  75444. }
  75445. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75446. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75447. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75448. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75449. interface WebGLRenderingContext {
  75450. readonly RASTERIZER_DISCARD: number;
  75451. readonly DEPTH_COMPONENT24: number;
  75452. readonly TEXTURE_3D: number;
  75453. readonly TEXTURE_2D_ARRAY: number;
  75454. readonly TEXTURE_COMPARE_FUNC: number;
  75455. readonly TEXTURE_COMPARE_MODE: number;
  75456. readonly COMPARE_REF_TO_TEXTURE: number;
  75457. readonly TEXTURE_WRAP_R: number;
  75458. readonly HALF_FLOAT: number;
  75459. readonly RGB8: number;
  75460. readonly RED_INTEGER: number;
  75461. readonly RG_INTEGER: number;
  75462. readonly RGB_INTEGER: number;
  75463. readonly RGBA_INTEGER: number;
  75464. readonly R8_SNORM: number;
  75465. readonly RG8_SNORM: number;
  75466. readonly RGB8_SNORM: number;
  75467. readonly RGBA8_SNORM: number;
  75468. readonly R8I: number;
  75469. readonly RG8I: number;
  75470. readonly RGB8I: number;
  75471. readonly RGBA8I: number;
  75472. readonly R8UI: number;
  75473. readonly RG8UI: number;
  75474. readonly RGB8UI: number;
  75475. readonly RGBA8UI: number;
  75476. readonly R16I: number;
  75477. readonly RG16I: number;
  75478. readonly RGB16I: number;
  75479. readonly RGBA16I: number;
  75480. readonly R16UI: number;
  75481. readonly RG16UI: number;
  75482. readonly RGB16UI: number;
  75483. readonly RGBA16UI: number;
  75484. readonly R32I: number;
  75485. readonly RG32I: number;
  75486. readonly RGB32I: number;
  75487. readonly RGBA32I: number;
  75488. readonly R32UI: number;
  75489. readonly RG32UI: number;
  75490. readonly RGB32UI: number;
  75491. readonly RGBA32UI: number;
  75492. readonly RGB10_A2UI: number;
  75493. readonly R11F_G11F_B10F: number;
  75494. readonly RGB9_E5: number;
  75495. readonly RGB10_A2: number;
  75496. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75497. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75498. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75499. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75500. readonly DEPTH_COMPONENT32F: number;
  75501. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75502. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75503. 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;
  75504. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75505. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75506. readonly TRANSFORM_FEEDBACK: number;
  75507. readonly INTERLEAVED_ATTRIBS: number;
  75508. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75509. createTransformFeedback(): WebGLTransformFeedback;
  75510. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75511. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75512. beginTransformFeedback(primitiveMode: number): void;
  75513. endTransformFeedback(): void;
  75514. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75515. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75516. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75517. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75518. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75519. }
  75520. interface ImageBitmap {
  75521. readonly width: number;
  75522. readonly height: number;
  75523. close(): void;
  75524. }
  75525. interface WebGLQuery extends WebGLObject {
  75526. }
  75527. declare var WebGLQuery: {
  75528. prototype: WebGLQuery;
  75529. new(): WebGLQuery;
  75530. };
  75531. interface WebGLSampler extends WebGLObject {
  75532. }
  75533. declare var WebGLSampler: {
  75534. prototype: WebGLSampler;
  75535. new(): WebGLSampler;
  75536. };
  75537. interface WebGLSync extends WebGLObject {
  75538. }
  75539. declare var WebGLSync: {
  75540. prototype: WebGLSync;
  75541. new(): WebGLSync;
  75542. };
  75543. interface WebGLTransformFeedback extends WebGLObject {
  75544. }
  75545. declare var WebGLTransformFeedback: {
  75546. prototype: WebGLTransformFeedback;
  75547. new(): WebGLTransformFeedback;
  75548. };
  75549. interface WebGLVertexArrayObject extends WebGLObject {
  75550. }
  75551. declare var WebGLVertexArrayObject: {
  75552. prototype: WebGLVertexArrayObject;
  75553. new(): WebGLVertexArrayObject;
  75554. };
  75555. // Type definitions for WebVR API
  75556. // Project: https://w3c.github.io/webvr/
  75557. // Definitions by: six a <https://github.com/lostfictions>
  75558. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75559. interface VRDisplay extends EventTarget {
  75560. /**
  75561. * Dictionary of capabilities describing the VRDisplay.
  75562. */
  75563. readonly capabilities: VRDisplayCapabilities;
  75564. /**
  75565. * z-depth defining the far plane of the eye view frustum
  75566. * enables mapping of values in the render target depth
  75567. * attachment to scene coordinates. Initially set to 10000.0.
  75568. */
  75569. depthFar: number;
  75570. /**
  75571. * z-depth defining the near plane of the eye view frustum
  75572. * enables mapping of values in the render target depth
  75573. * attachment to scene coordinates. Initially set to 0.01.
  75574. */
  75575. depthNear: number;
  75576. /**
  75577. * An identifier for this distinct VRDisplay. Used as an
  75578. * association point in the Gamepad API.
  75579. */
  75580. readonly displayId: number;
  75581. /**
  75582. * A display name, a user-readable name identifying it.
  75583. */
  75584. readonly displayName: string;
  75585. readonly isConnected: boolean;
  75586. readonly isPresenting: boolean;
  75587. /**
  75588. * If this VRDisplay supports room-scale experiences, the optional
  75589. * stage attribute contains details on the room-scale parameters.
  75590. */
  75591. readonly stageParameters: VRStageParameters | null;
  75592. /**
  75593. * Passing the value returned by `requestAnimationFrame` to
  75594. * `cancelAnimationFrame` will unregister the callback.
  75595. * @param handle Define the hanle of the request to cancel
  75596. */
  75597. cancelAnimationFrame(handle: number): void;
  75598. /**
  75599. * Stops presenting to the VRDisplay.
  75600. * @returns a promise to know when it stopped
  75601. */
  75602. exitPresent(): Promise<void>;
  75603. /**
  75604. * Return the current VREyeParameters for the given eye.
  75605. * @param whichEye Define the eye we want the parameter for
  75606. * @returns the eye parameters
  75607. */
  75608. getEyeParameters(whichEye: string): VREyeParameters;
  75609. /**
  75610. * Populates the passed VRFrameData with the information required to render
  75611. * the current frame.
  75612. * @param frameData Define the data structure to populate
  75613. * @returns true if ok otherwise false
  75614. */
  75615. getFrameData(frameData: VRFrameData): boolean;
  75616. /**
  75617. * Get the layers currently being presented.
  75618. * @returns the list of VR layers
  75619. */
  75620. getLayers(): VRLayer[];
  75621. /**
  75622. * Return a VRPose containing the future predicted pose of the VRDisplay
  75623. * when the current frame will be presented. The value returned will not
  75624. * change until JavaScript has returned control to the browser.
  75625. *
  75626. * The VRPose will contain the position, orientation, velocity,
  75627. * and acceleration of each of these properties.
  75628. * @returns the pose object
  75629. */
  75630. getPose(): VRPose;
  75631. /**
  75632. * Return the current instantaneous pose of the VRDisplay, with no
  75633. * prediction applied.
  75634. * @returns the current instantaneous pose
  75635. */
  75636. getImmediatePose(): VRPose;
  75637. /**
  75638. * The callback passed to `requestAnimationFrame` will be called
  75639. * any time a new frame should be rendered. When the VRDisplay is
  75640. * presenting the callback will be called at the native refresh
  75641. * rate of the HMD. When not presenting this function acts
  75642. * identically to how window.requestAnimationFrame acts. Content should
  75643. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75644. * asynchronously from other displays and at differing refresh rates.
  75645. * @param callback Define the eaction to run next frame
  75646. * @returns the request handle it
  75647. */
  75648. requestAnimationFrame(callback: FrameRequestCallback): number;
  75649. /**
  75650. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75651. * Repeat calls while already presenting will update the VRLayers being displayed.
  75652. * @param layers Define the list of layer to present
  75653. * @returns a promise to know when the request has been fulfilled
  75654. */
  75655. requestPresent(layers: VRLayer[]): Promise<void>;
  75656. /**
  75657. * Reset the pose for this display, treating its current position and
  75658. * orientation as the "origin/zero" values. VRPose.position,
  75659. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75660. * updated when calling resetPose(). This should be called in only
  75661. * sitting-space experiences.
  75662. */
  75663. resetPose(): void;
  75664. /**
  75665. * The VRLayer provided to the VRDisplay will be captured and presented
  75666. * in the HMD. Calling this function has the same effect on the source
  75667. * canvas as any other operation that uses its source image, and canvases
  75668. * created without preserveDrawingBuffer set to true will be cleared.
  75669. * @param pose Define the pose to submit
  75670. */
  75671. submitFrame(pose?: VRPose): void;
  75672. }
  75673. declare var VRDisplay: {
  75674. prototype: VRDisplay;
  75675. new(): VRDisplay;
  75676. };
  75677. interface VRLayer {
  75678. leftBounds?: number[] | Float32Array | null;
  75679. rightBounds?: number[] | Float32Array | null;
  75680. source?: HTMLCanvasElement | null;
  75681. }
  75682. interface VRDisplayCapabilities {
  75683. readonly canPresent: boolean;
  75684. readonly hasExternalDisplay: boolean;
  75685. readonly hasOrientation: boolean;
  75686. readonly hasPosition: boolean;
  75687. readonly maxLayers: number;
  75688. }
  75689. interface VREyeParameters {
  75690. /** @deprecated */
  75691. readonly fieldOfView: VRFieldOfView;
  75692. readonly offset: Float32Array;
  75693. readonly renderHeight: number;
  75694. readonly renderWidth: number;
  75695. }
  75696. interface VRFieldOfView {
  75697. readonly downDegrees: number;
  75698. readonly leftDegrees: number;
  75699. readonly rightDegrees: number;
  75700. readonly upDegrees: number;
  75701. }
  75702. interface VRFrameData {
  75703. readonly leftProjectionMatrix: Float32Array;
  75704. readonly leftViewMatrix: Float32Array;
  75705. readonly pose: VRPose;
  75706. readonly rightProjectionMatrix: Float32Array;
  75707. readonly rightViewMatrix: Float32Array;
  75708. readonly timestamp: number;
  75709. }
  75710. interface VRPose {
  75711. readonly angularAcceleration: Float32Array | null;
  75712. readonly angularVelocity: Float32Array | null;
  75713. readonly linearAcceleration: Float32Array | null;
  75714. readonly linearVelocity: Float32Array | null;
  75715. readonly orientation: Float32Array | null;
  75716. readonly position: Float32Array | null;
  75717. readonly timestamp: number;
  75718. }
  75719. interface VRStageParameters {
  75720. sittingToStandingTransform?: Float32Array;
  75721. sizeX?: number;
  75722. sizeY?: number;
  75723. }
  75724. interface Navigator {
  75725. getVRDisplays(): Promise<VRDisplay[]>;
  75726. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75727. }
  75728. interface Window {
  75729. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75730. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75731. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75732. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75733. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75734. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75735. }
  75736. interface Gamepad {
  75737. readonly displayId: number;
  75738. }
  75739. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75740. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75741. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75742. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75743. type XRHandedness = "none" | "left" | "right";
  75744. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75745. type XREye = "none" | "left" | "right";
  75746. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75747. interface XRSpace extends EventTarget {}
  75748. interface XRRenderState {
  75749. depthNear?: number;
  75750. depthFar?: number;
  75751. inlineVerticalFieldOfView?: number;
  75752. baseLayer?: XRWebGLLayer;
  75753. }
  75754. interface XRInputSource {
  75755. handedness: XRHandedness;
  75756. targetRayMode: XRTargetRayMode;
  75757. targetRaySpace: XRSpace;
  75758. gripSpace: XRSpace | undefined;
  75759. gamepad: Gamepad | undefined;
  75760. profiles: Array<string>;
  75761. hand: XRHand | undefined;
  75762. }
  75763. interface XRSessionInit {
  75764. optionalFeatures?: string[];
  75765. requiredFeatures?: string[];
  75766. }
  75767. interface XRSession {
  75768. addEventListener: Function;
  75769. removeEventListener: Function;
  75770. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75771. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75772. requestAnimationFrame: Function;
  75773. end(): Promise<void>;
  75774. renderState: XRRenderState;
  75775. inputSources: Array<XRInputSource>;
  75776. // hit test
  75777. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75778. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75779. // legacy AR hit test
  75780. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75781. // legacy plane detection
  75782. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  75783. }
  75784. interface XRReferenceSpace extends XRSpace {
  75785. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75786. onreset: any;
  75787. }
  75788. type XRPlaneSet = Set<XRPlane>;
  75789. type XRAnchorSet = Set<XRAnchor>;
  75790. interface XRFrame {
  75791. session: XRSession;
  75792. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75793. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75794. // AR
  75795. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  75796. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75797. // Anchors
  75798. trackedAnchors?: XRAnchorSet;
  75799. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75800. // Planes
  75801. worldInformation: {
  75802. detectedPlanes?: XRPlaneSet;
  75803. };
  75804. // Hand tracking
  75805. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  75806. }
  75807. interface XRViewerPose extends XRPose {
  75808. views: Array<XRView>;
  75809. }
  75810. interface XRPose {
  75811. transform: XRRigidTransform;
  75812. emulatedPosition: boolean;
  75813. }
  75814. interface XRWebGLLayerOptions {
  75815. antialias?: boolean;
  75816. depth?: boolean;
  75817. stencil?: boolean;
  75818. alpha?: boolean;
  75819. multiview?: boolean;
  75820. framebufferScaleFactor?: number;
  75821. }
  75822. declare var XRWebGLLayer: {
  75823. prototype: XRWebGLLayer;
  75824. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75825. };
  75826. interface XRWebGLLayer {
  75827. framebuffer: WebGLFramebuffer;
  75828. framebufferWidth: number;
  75829. framebufferHeight: number;
  75830. getViewport: Function;
  75831. }
  75832. declare class XRRigidTransform {
  75833. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75834. position: DOMPointReadOnly;
  75835. orientation: DOMPointReadOnly;
  75836. matrix: Float32Array;
  75837. inverse: XRRigidTransform;
  75838. }
  75839. interface XRView {
  75840. eye: XREye;
  75841. projectionMatrix: Float32Array;
  75842. transform: XRRigidTransform;
  75843. }
  75844. interface XRInputSourceChangeEvent {
  75845. session: XRSession;
  75846. removed: Array<XRInputSource>;
  75847. added: Array<XRInputSource>;
  75848. }
  75849. interface XRInputSourceEvent extends Event {
  75850. readonly frame: XRFrame;
  75851. readonly inputSource: XRInputSource;
  75852. }
  75853. // Experimental(er) features
  75854. declare class XRRay {
  75855. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75856. origin: DOMPointReadOnly;
  75857. direction: DOMPointReadOnly;
  75858. matrix: Float32Array;
  75859. }
  75860. declare enum XRHitTestTrackableType {
  75861. "point",
  75862. "plane",
  75863. "mesh",
  75864. }
  75865. interface XRHitResult {
  75866. hitMatrix: Float32Array;
  75867. }
  75868. interface XRTransientInputHitTestResult {
  75869. readonly inputSource: XRInputSource;
  75870. readonly results: Array<XRHitTestResult>;
  75871. }
  75872. interface XRHitTestResult {
  75873. getPose(baseSpace: XRSpace): XRPose | undefined;
  75874. // When anchor system is enabled
  75875. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75876. }
  75877. interface XRHitTestSource {
  75878. cancel(): void;
  75879. }
  75880. interface XRTransientInputHitTestSource {
  75881. cancel(): void;
  75882. }
  75883. interface XRHitTestOptionsInit {
  75884. space: XRSpace;
  75885. entityTypes?: Array<XRHitTestTrackableType>;
  75886. offsetRay?: XRRay;
  75887. }
  75888. interface XRTransientInputHitTestOptionsInit {
  75889. profile: string;
  75890. entityTypes?: Array<XRHitTestTrackableType>;
  75891. offsetRay?: XRRay;
  75892. }
  75893. interface XRAnchor {
  75894. anchorSpace: XRSpace;
  75895. delete(): void;
  75896. }
  75897. interface XRPlane {
  75898. orientation: "Horizontal" | "Vertical";
  75899. planeSpace: XRSpace;
  75900. polygon: Array<DOMPointReadOnly>;
  75901. lastChangedTime: number;
  75902. }
  75903. interface XRJointSpace extends XRSpace {}
  75904. interface XRJointPose extends XRPose {
  75905. radius: number | undefined;
  75906. }
  75907. declare class XRHand extends Array<XRJointSpace> {
  75908. readonly length: number;
  75909. static readonly WRIST = 0;
  75910. static readonly THUMB_METACARPAL = 1;
  75911. static readonly THUMB_PHALANX_PROXIMAL = 2;
  75912. static readonly THUMB_PHALANX_DISTAL = 3;
  75913. static readonly THUMB_PHALANX_TIP = 4;
  75914. static readonly INDEX_METACARPAL = 5;
  75915. static readonly INDEX_PHALANX_PROXIMAL = 6;
  75916. static readonly INDEX_PHALANX_INTERMEDIATE = 7;
  75917. static readonly INDEX_PHALANX_DISTAL = 8;
  75918. static readonly INDEX_PHALANX_TIP = 9;
  75919. static readonly MIDDLE_METACARPAL = 10;
  75920. static readonly MIDDLE_PHALANX_PROXIMAL = 11;
  75921. static readonly MIDDLE_PHALANX_INTERMEDIATE = 12;
  75922. static readonly MIDDLE_PHALANX_DISTAL = 13;
  75923. static readonly MIDDLE_PHALANX_TIP = 14;
  75924. static readonly RING_METACARPAL = 15;
  75925. static readonly RING_PHALANX_PROXIMAL = 16;
  75926. static readonly RING_PHALANX_INTERMEDIATE = 17;
  75927. static readonly RING_PHALANX_DISTAL = 18;
  75928. static readonly RING_PHALANX_TIP = 19;
  75929. static readonly LITTLE_METACARPAL = 20;
  75930. static readonly LITTLE_PHALANX_PROXIMAL = 21;
  75931. static readonly LITTLE_PHALANX_INTERMEDIATE = 22;
  75932. static readonly LITTLE_PHALANX_DISTAL = 23;
  75933. static readonly LITTLE_PHALANX_TIP = 24;
  75934. }
  75935. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  75936. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  75937. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  75938. interface XRSession {
  75939. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  75940. }
  75941. interface XRFrame {
  75942. featurePointCloud? : Array<number>;
  75943. }
  75944. /**
  75945. * @ignore
  75946. */
  75947. declare module BABYLON.GLTF2.Exporter {
  75948. }
  75949. /**
  75950. * @ignore
  75951. */
  75952. declare module BABYLON.GLTF1 {
  75953. }
  75954. declare module BABYLON.GUI {
  75955. /**
  75956. * Class used to specific a value and its associated unit
  75957. */
  75958. export class ValueAndUnit {
  75959. /** defines the unit to store */
  75960. unit: number;
  75961. /** defines a boolean indicating if the value can be negative */
  75962. negativeValueAllowed: boolean;
  75963. private _value;
  75964. private _originalUnit;
  75965. /**
  75966. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75967. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75968. */
  75969. ignoreAdaptiveScaling: boolean;
  75970. /**
  75971. * Creates a new ValueAndUnit
  75972. * @param value defines the value to store
  75973. * @param unit defines the unit to store
  75974. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75975. */
  75976. constructor(value: number,
  75977. /** defines the unit to store */
  75978. unit?: number,
  75979. /** defines a boolean indicating if the value can be negative */
  75980. negativeValueAllowed?: boolean);
  75981. /** Gets a boolean indicating if the value is a percentage */
  75982. get isPercentage(): boolean;
  75983. /** Gets a boolean indicating if the value is store as pixel */
  75984. get isPixel(): boolean;
  75985. /** Gets direct internal value */
  75986. get internalValue(): number;
  75987. /**
  75988. * Gets value as pixel
  75989. * @param host defines the root host
  75990. * @param refValue defines the reference value for percentages
  75991. * @returns the value as pixel
  75992. */
  75993. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75994. /**
  75995. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75996. * @param value defines the value to store
  75997. * @param unit defines the unit to store
  75998. * @returns the current ValueAndUnit
  75999. */
  76000. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76001. /**
  76002. * Gets the value accordingly to its unit
  76003. * @param host defines the root host
  76004. * @returns the value
  76005. */
  76006. getValue(host: AdvancedDynamicTexture): number;
  76007. /**
  76008. * Gets a string representation of the value
  76009. * @param host defines the root host
  76010. * @param decimals defines an optional number of decimals to display
  76011. * @returns a string
  76012. */
  76013. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76014. /**
  76015. * Store a value parsed from a string
  76016. * @param source defines the source string
  76017. * @returns true if the value was successfully parsed
  76018. */
  76019. fromString(source: string | number): boolean;
  76020. private static _Regex;
  76021. private static _UNITMODE_PERCENTAGE;
  76022. private static _UNITMODE_PIXEL;
  76023. /** UNITMODE_PERCENTAGE */
  76024. static get UNITMODE_PERCENTAGE(): number;
  76025. /** UNITMODE_PIXEL */
  76026. static get UNITMODE_PIXEL(): number;
  76027. }
  76028. }
  76029. declare module BABYLON.GUI {
  76030. /**
  76031. * Define a style used by control to automatically setup properties based on a template.
  76032. * Only support font related properties so far
  76033. */
  76034. export class Style implements BABYLON.IDisposable {
  76035. private _fontFamily;
  76036. private _fontStyle;
  76037. private _fontWeight;
  76038. /** @hidden */
  76039. _host: AdvancedDynamicTexture;
  76040. /** @hidden */
  76041. _fontSize: ValueAndUnit;
  76042. /**
  76043. * BABYLON.Observable raised when the style values are changed
  76044. */
  76045. onChangedObservable: BABYLON.Observable<Style>;
  76046. /**
  76047. * Creates a new style object
  76048. * @param host defines the AdvancedDynamicTexture which hosts this style
  76049. */
  76050. constructor(host: AdvancedDynamicTexture);
  76051. /**
  76052. * Gets or sets the font size
  76053. */
  76054. get fontSize(): string | number;
  76055. set fontSize(value: string | number);
  76056. /**
  76057. * Gets or sets the font family
  76058. */
  76059. get fontFamily(): string;
  76060. set fontFamily(value: string);
  76061. /**
  76062. * Gets or sets the font style
  76063. */
  76064. get fontStyle(): string;
  76065. set fontStyle(value: string);
  76066. /** Gets or sets font weight */
  76067. get fontWeight(): string;
  76068. set fontWeight(value: string);
  76069. /** Dispose all associated resources */
  76070. dispose(): void;
  76071. }
  76072. }
  76073. declare module BABYLON.GUI {
  76074. /**
  76075. * Class used to transport BABYLON.Vector2 information for pointer events
  76076. */
  76077. export class Vector2WithInfo extends BABYLON.Vector2 {
  76078. /** defines the current mouse button index */
  76079. buttonIndex: number;
  76080. /**
  76081. * Creates a new Vector2WithInfo
  76082. * @param source defines the vector2 data to transport
  76083. * @param buttonIndex defines the current mouse button index
  76084. */
  76085. constructor(source: BABYLON.Vector2,
  76086. /** defines the current mouse button index */
  76087. buttonIndex?: number);
  76088. }
  76089. /** Class used to provide 2D matrix features */
  76090. export class Matrix2D {
  76091. /** Gets the internal array of 6 floats used to store matrix data */
  76092. m: Float32Array;
  76093. /**
  76094. * Creates a new matrix
  76095. * @param m00 defines value for (0, 0)
  76096. * @param m01 defines value for (0, 1)
  76097. * @param m10 defines value for (1, 0)
  76098. * @param m11 defines value for (1, 1)
  76099. * @param m20 defines value for (2, 0)
  76100. * @param m21 defines value for (2, 1)
  76101. */
  76102. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76103. /**
  76104. * Fills the matrix from direct values
  76105. * @param m00 defines value for (0, 0)
  76106. * @param m01 defines value for (0, 1)
  76107. * @param m10 defines value for (1, 0)
  76108. * @param m11 defines value for (1, 1)
  76109. * @param m20 defines value for (2, 0)
  76110. * @param m21 defines value for (2, 1)
  76111. * @returns the current modified matrix
  76112. */
  76113. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76114. /**
  76115. * Gets matrix determinant
  76116. * @returns the determinant
  76117. */
  76118. determinant(): number;
  76119. /**
  76120. * Inverses the matrix and stores it in a target matrix
  76121. * @param result defines the target matrix
  76122. * @returns the current matrix
  76123. */
  76124. invertToRef(result: Matrix2D): Matrix2D;
  76125. /**
  76126. * Multiplies the current matrix with another one
  76127. * @param other defines the second operand
  76128. * @param result defines the target matrix
  76129. * @returns the current matrix
  76130. */
  76131. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76132. /**
  76133. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76134. * @param x defines the x coordinate to transform
  76135. * @param y defines the x coordinate to transform
  76136. * @param result defines the target vector2
  76137. * @returns the current matrix
  76138. */
  76139. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76140. /**
  76141. * Creates an identity matrix
  76142. * @returns a new matrix
  76143. */
  76144. static Identity(): Matrix2D;
  76145. /**
  76146. * Creates a translation matrix and stores it in a target matrix
  76147. * @param x defines the x coordinate of the translation
  76148. * @param y defines the y coordinate of the translation
  76149. * @param result defines the target matrix
  76150. */
  76151. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76152. /**
  76153. * Creates a scaling matrix and stores it in a target matrix
  76154. * @param x defines the x coordinate of the scaling
  76155. * @param y defines the y coordinate of the scaling
  76156. * @param result defines the target matrix
  76157. */
  76158. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76159. /**
  76160. * Creates a rotation matrix and stores it in a target matrix
  76161. * @param angle defines the rotation angle
  76162. * @param result defines the target matrix
  76163. */
  76164. static RotationToRef(angle: number, result: Matrix2D): void;
  76165. private static _TempPreTranslationMatrix;
  76166. private static _TempPostTranslationMatrix;
  76167. private static _TempRotationMatrix;
  76168. private static _TempScalingMatrix;
  76169. private static _TempCompose0;
  76170. private static _TempCompose1;
  76171. private static _TempCompose2;
  76172. /**
  76173. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76174. * @param tx defines the x coordinate of the translation
  76175. * @param ty defines the y coordinate of the translation
  76176. * @param angle defines the rotation angle
  76177. * @param scaleX defines the x coordinate of the scaling
  76178. * @param scaleY defines the y coordinate of the scaling
  76179. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76180. * @param result defines the target matrix
  76181. */
  76182. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76183. }
  76184. }
  76185. declare module BABYLON.GUI {
  76186. /**
  76187. * Class used to store 2D control sizes
  76188. */
  76189. export class Measure {
  76190. /** defines left coordinate */
  76191. left: number;
  76192. /** defines top coordinate */
  76193. top: number;
  76194. /** defines width dimension */
  76195. width: number;
  76196. /** defines height dimension */
  76197. height: number;
  76198. /**
  76199. * Creates a new measure
  76200. * @param left defines left coordinate
  76201. * @param top defines top coordinate
  76202. * @param width defines width dimension
  76203. * @param height defines height dimension
  76204. */
  76205. constructor(
  76206. /** defines left coordinate */
  76207. left: number,
  76208. /** defines top coordinate */
  76209. top: number,
  76210. /** defines width dimension */
  76211. width: number,
  76212. /** defines height dimension */
  76213. height: number);
  76214. /**
  76215. * Copy from another measure
  76216. * @param other defines the other measure to copy from
  76217. */
  76218. copyFrom(other: Measure): void;
  76219. /**
  76220. * Copy from a group of 4 floats
  76221. * @param left defines left coordinate
  76222. * @param top defines top coordinate
  76223. * @param width defines width dimension
  76224. * @param height defines height dimension
  76225. */
  76226. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76227. /**
  76228. * Computes the axis aligned bounding box measure for two given measures
  76229. * @param a Input measure
  76230. * @param b Input measure
  76231. * @param result the resulting bounding measure
  76232. */
  76233. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76234. /**
  76235. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76236. * @param transform the matrix to transform the measure before computing the AABB
  76237. * @param addX number to add to left
  76238. * @param addY number to add to top
  76239. * @param addWidth number to add to width
  76240. * @param addHeight number to add to height
  76241. * @param result the resulting AABB
  76242. */
  76243. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76244. /**
  76245. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76246. * @param transform the matrix to transform the measure before computing the AABB
  76247. * @param result the resulting AABB
  76248. */
  76249. transformToRef(transform: Matrix2D, result: Measure): void;
  76250. /**
  76251. * Check equality between this measure and another one
  76252. * @param other defines the other measures
  76253. * @returns true if both measures are equals
  76254. */
  76255. isEqualsTo(other: Measure): boolean;
  76256. /**
  76257. * Creates an empty measure
  76258. * @returns a new measure
  76259. */
  76260. static Empty(): Measure;
  76261. }
  76262. }
  76263. declare module BABYLON.GUI {
  76264. /**
  76265. * Interface used to define a control that can receive focus
  76266. */
  76267. export interface IFocusableControl {
  76268. /**
  76269. * Function called when the control receives the focus
  76270. */
  76271. onFocus(): void;
  76272. /**
  76273. * Function called when the control loses the focus
  76274. */
  76275. onBlur(): void;
  76276. /**
  76277. * Function called to let the control handle keyboard events
  76278. * @param evt defines the current keyboard event
  76279. */
  76280. processKeyboard(evt: KeyboardEvent): void;
  76281. /**
  76282. * Function called to get the list of controls that should not steal the focus from this control
  76283. * @returns an array of controls
  76284. */
  76285. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76286. }
  76287. /**
  76288. * Class used to create texture to support 2D GUI elements
  76289. * @see https://doc.babylonjs.com/how_to/gui
  76290. */
  76291. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76292. private _isDirty;
  76293. private _renderObserver;
  76294. private _resizeObserver;
  76295. private _preKeyboardObserver;
  76296. private _pointerMoveObserver;
  76297. private _pointerObserver;
  76298. private _canvasPointerOutObserver;
  76299. private _canvasBlurObserver;
  76300. private _background;
  76301. /** @hidden */
  76302. _rootContainer: Container;
  76303. /** @hidden */
  76304. _lastPickedControl: Control;
  76305. /** @hidden */
  76306. _lastControlOver: {
  76307. [pointerId: number]: Control;
  76308. };
  76309. /** @hidden */
  76310. _lastControlDown: {
  76311. [pointerId: number]: Control;
  76312. };
  76313. /** @hidden */
  76314. _capturingControl: {
  76315. [pointerId: number]: Control;
  76316. };
  76317. /** @hidden */
  76318. _shouldBlockPointer: boolean;
  76319. /** @hidden */
  76320. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76321. /** @hidden */
  76322. _linkedControls: Control[];
  76323. private _isFullscreen;
  76324. private _fullscreenViewport;
  76325. private _idealWidth;
  76326. private _idealHeight;
  76327. private _useSmallestIdeal;
  76328. private _renderAtIdealSize;
  76329. private _focusedControl;
  76330. private _blockNextFocusCheck;
  76331. private _renderScale;
  76332. private _rootElement;
  76333. private _cursorChanged;
  76334. private _defaultMousePointerId;
  76335. /** @hidden */
  76336. _numLayoutCalls: number;
  76337. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76338. get numLayoutCalls(): number;
  76339. /** @hidden */
  76340. _numRenderCalls: number;
  76341. /** Gets the number of render calls made the last time the ADT has been rendered */
  76342. get numRenderCalls(): number;
  76343. /**
  76344. * Define type to string to ensure compatibility across browsers
  76345. * Safari doesn't support DataTransfer constructor
  76346. */
  76347. private _clipboardData;
  76348. /**
  76349. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76350. */
  76351. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76352. /**
  76353. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76354. */
  76355. onControlPickedObservable: BABYLON.Observable<Control>;
  76356. /**
  76357. * BABYLON.Observable event triggered before layout is evaluated
  76358. */
  76359. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76360. /**
  76361. * BABYLON.Observable event triggered after the layout was evaluated
  76362. */
  76363. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76364. /**
  76365. * BABYLON.Observable event triggered before the texture is rendered
  76366. */
  76367. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76368. /**
  76369. * BABYLON.Observable event triggered after the texture was rendered
  76370. */
  76371. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76372. /**
  76373. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76374. */
  76375. premulAlpha: boolean;
  76376. /**
  76377. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76378. * Useful when you want more antialiasing
  76379. */
  76380. get renderScale(): number;
  76381. set renderScale(value: number);
  76382. /** Gets or sets the background color */
  76383. get background(): string;
  76384. set background(value: string);
  76385. /**
  76386. * Gets or sets the ideal width used to design controls.
  76387. * The GUI will then rescale everything accordingly
  76388. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76389. */
  76390. get idealWidth(): number;
  76391. set idealWidth(value: number);
  76392. /**
  76393. * Gets or sets the ideal height used to design controls.
  76394. * The GUI will then rescale everything accordingly
  76395. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76396. */
  76397. get idealHeight(): number;
  76398. set idealHeight(value: number);
  76399. /**
  76400. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76401. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76402. */
  76403. get useSmallestIdeal(): boolean;
  76404. set useSmallestIdeal(value: boolean);
  76405. /**
  76406. * Gets or sets a boolean indicating if adaptive scaling must be used
  76407. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76408. */
  76409. get renderAtIdealSize(): boolean;
  76410. set renderAtIdealSize(value: boolean);
  76411. /**
  76412. * Gets the ratio used when in "ideal mode"
  76413. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76414. * */
  76415. get idealRatio(): number;
  76416. /**
  76417. * Gets the underlying layer used to render the texture when in fullscreen mode
  76418. */
  76419. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76420. /**
  76421. * Gets the root container control
  76422. */
  76423. get rootContainer(): Container;
  76424. /**
  76425. * Returns an array containing the root container.
  76426. * This is mostly used to let the Inspector introspects the ADT
  76427. * @returns an array containing the rootContainer
  76428. */
  76429. getChildren(): Array<Container>;
  76430. /**
  76431. * Will return all controls that are inside this texture
  76432. * @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
  76433. * @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
  76434. * @return all child controls
  76435. */
  76436. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76437. /**
  76438. * Gets or sets the current focused control
  76439. */
  76440. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76441. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76442. /**
  76443. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76444. */
  76445. get isForeground(): boolean;
  76446. set isForeground(value: boolean);
  76447. /**
  76448. * Gets or set information about clipboardData
  76449. */
  76450. get clipboardData(): string;
  76451. set clipboardData(value: string);
  76452. /**
  76453. * Creates a new AdvancedDynamicTexture
  76454. * @param name defines the name of the texture
  76455. * @param width defines the width of the texture
  76456. * @param height defines the height of the texture
  76457. * @param scene defines the hosting scene
  76458. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76459. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76460. */
  76461. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76462. /**
  76463. * Get the current class name of the texture useful for serialization or dynamic coding.
  76464. * @returns "AdvancedDynamicTexture"
  76465. */
  76466. getClassName(): string;
  76467. /**
  76468. * Function used to execute a function on all controls
  76469. * @param func defines the function to execute
  76470. * @param container defines the container where controls belong. If null the root container will be used
  76471. */
  76472. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76473. private _useInvalidateRectOptimization;
  76474. /**
  76475. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76476. */
  76477. get useInvalidateRectOptimization(): boolean;
  76478. set useInvalidateRectOptimization(value: boolean);
  76479. private _invalidatedRectangle;
  76480. /**
  76481. * Invalidates a rectangle area on the gui texture
  76482. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76483. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76484. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76485. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76486. */
  76487. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76488. /**
  76489. * Marks the texture as dirty forcing a complete update
  76490. */
  76491. markAsDirty(): void;
  76492. /**
  76493. * Helper function used to create a new style
  76494. * @returns a new style
  76495. * @see https://doc.babylonjs.com/how_to/gui#styles
  76496. */
  76497. createStyle(): Style;
  76498. /**
  76499. * Adds a new control to the root container
  76500. * @param control defines the control to add
  76501. * @returns the current texture
  76502. */
  76503. addControl(control: Control): AdvancedDynamicTexture;
  76504. /**
  76505. * Removes a control from the root container
  76506. * @param control defines the control to remove
  76507. * @returns the current texture
  76508. */
  76509. removeControl(control: Control): AdvancedDynamicTexture;
  76510. /**
  76511. * Release all resources
  76512. */
  76513. dispose(): void;
  76514. private _onResize;
  76515. /** @hidden */
  76516. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76517. /**
  76518. * Get screen coordinates for a vector3
  76519. * @param position defines the position to project
  76520. * @param worldMatrix defines the world matrix to use
  76521. * @returns the projected position
  76522. */
  76523. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76524. private _checkUpdate;
  76525. private _clearMeasure;
  76526. private _render;
  76527. /** @hidden */
  76528. _changeCursor(cursor: string): void;
  76529. /** @hidden */
  76530. _registerLastControlDown(control: Control, pointerId: number): void;
  76531. private _doPicking;
  76532. /** @hidden */
  76533. _cleanControlAfterRemovalFromList(list: {
  76534. [pointerId: number]: Control;
  76535. }, control: Control): void;
  76536. /** @hidden */
  76537. _cleanControlAfterRemoval(control: Control): void;
  76538. /** Attach to all scene events required to support pointer events */
  76539. attach(): void;
  76540. /** @hidden */
  76541. private onClipboardCopy;
  76542. /** @hidden */
  76543. private onClipboardCut;
  76544. /** @hidden */
  76545. private onClipboardPaste;
  76546. /**
  76547. * Register the clipboard Events onto the canvas
  76548. */
  76549. registerClipboardEvents(): void;
  76550. /**
  76551. * Unregister the clipboard Events from the canvas
  76552. */
  76553. unRegisterClipboardEvents(): void;
  76554. /**
  76555. * Connect the texture to a hosting mesh to enable interactions
  76556. * @param mesh defines the mesh to attach to
  76557. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76558. */
  76559. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76560. /**
  76561. * Move the focus to a specific control
  76562. * @param control defines the control which will receive the focus
  76563. */
  76564. moveFocusToControl(control: IFocusableControl): void;
  76565. private _manageFocus;
  76566. private _attachToOnPointerOut;
  76567. private _attachToOnBlur;
  76568. /**
  76569. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76570. * @param mesh defines the mesh which will receive the texture
  76571. * @param width defines the texture width (1024 by default)
  76572. * @param height defines the texture height (1024 by default)
  76573. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76574. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76575. * @returns a new AdvancedDynamicTexture
  76576. */
  76577. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76578. /**
  76579. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76580. * In this mode the texture will rely on a layer for its rendering.
  76581. * This allows it to be treated like any other layer.
  76582. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76583. * LayerMask is set through advancedTexture.layer.layerMask
  76584. * @param name defines name for the texture
  76585. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76586. * @param scene defines the hsoting scene
  76587. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76588. * @returns a new AdvancedDynamicTexture
  76589. */
  76590. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76591. }
  76592. }
  76593. declare module BABYLON.GUI {
  76594. /**
  76595. * Root class used for all 2D controls
  76596. * @see https://doc.babylonjs.com/how_to/gui#controls
  76597. */
  76598. export class Control {
  76599. /** defines the name of the control */
  76600. name?: string | undefined;
  76601. /**
  76602. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76603. */
  76604. static AllowAlphaInheritance: boolean;
  76605. private _alpha;
  76606. private _alphaSet;
  76607. private _zIndex;
  76608. /** @hidden */
  76609. _host: AdvancedDynamicTexture;
  76610. /** Gets or sets the control parent */
  76611. parent: BABYLON.Nullable<Container>;
  76612. /** @hidden */
  76613. _currentMeasure: Measure;
  76614. private _fontFamily;
  76615. private _fontStyle;
  76616. private _fontWeight;
  76617. private _fontSize;
  76618. private _font;
  76619. /** @hidden */
  76620. _width: ValueAndUnit;
  76621. /** @hidden */
  76622. _height: ValueAndUnit;
  76623. /** @hidden */
  76624. protected _fontOffset: {
  76625. ascent: number;
  76626. height: number;
  76627. descent: number;
  76628. };
  76629. private _color;
  76630. private _style;
  76631. private _styleObserver;
  76632. /** @hidden */
  76633. protected _horizontalAlignment: number;
  76634. /** @hidden */
  76635. protected _verticalAlignment: number;
  76636. /** @hidden */
  76637. protected _isDirty: boolean;
  76638. /** @hidden */
  76639. protected _wasDirty: boolean;
  76640. /** @hidden */
  76641. _tempParentMeasure: Measure;
  76642. /** @hidden */
  76643. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76644. /** @hidden */
  76645. protected _cachedParentMeasure: Measure;
  76646. private _paddingLeft;
  76647. private _paddingRight;
  76648. private _paddingTop;
  76649. private _paddingBottom;
  76650. /** @hidden */
  76651. _left: ValueAndUnit;
  76652. /** @hidden */
  76653. _top: ValueAndUnit;
  76654. private _scaleX;
  76655. private _scaleY;
  76656. private _rotation;
  76657. private _transformCenterX;
  76658. private _transformCenterY;
  76659. /** @hidden */
  76660. _transformMatrix: Matrix2D;
  76661. /** @hidden */
  76662. protected _invertTransformMatrix: Matrix2D;
  76663. /** @hidden */
  76664. protected _transformedPosition: BABYLON.Vector2;
  76665. private _isMatrixDirty;
  76666. private _cachedOffsetX;
  76667. private _cachedOffsetY;
  76668. private _isVisible;
  76669. private _isHighlighted;
  76670. /** @hidden */
  76671. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76672. private _fontSet;
  76673. private _dummyVector2;
  76674. private _downCount;
  76675. private _enterCount;
  76676. private _doNotRender;
  76677. private _downPointerIds;
  76678. protected _isEnabled: boolean;
  76679. protected _disabledColor: string;
  76680. protected _disabledColorItem: string;
  76681. /** @hidden */
  76682. protected _rebuildLayout: boolean;
  76683. /** @hidden */
  76684. _customData: any;
  76685. /** @hidden */
  76686. _isClipped: boolean;
  76687. /** @hidden */
  76688. _automaticSize: boolean;
  76689. /** @hidden */
  76690. _tag: any;
  76691. /**
  76692. * 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
  76693. */
  76694. uniqueId: number;
  76695. /**
  76696. * Gets or sets an object used to store user defined information for the node
  76697. */
  76698. metadata: any;
  76699. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76700. isHitTestVisible: boolean;
  76701. /** Gets or sets a boolean indicating if the control can block pointer events */
  76702. isPointerBlocker: boolean;
  76703. /** Gets or sets a boolean indicating if the control can be focusable */
  76704. isFocusInvisible: boolean;
  76705. /**
  76706. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76707. * 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
  76708. */
  76709. clipChildren: boolean;
  76710. /**
  76711. * Gets or sets a boolean indicating that control content must be clipped
  76712. * 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
  76713. */
  76714. clipContent: boolean;
  76715. /**
  76716. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76717. */
  76718. useBitmapCache: boolean;
  76719. private _cacheData;
  76720. private _shadowOffsetX;
  76721. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76722. get shadowOffsetX(): number;
  76723. set shadowOffsetX(value: number);
  76724. private _shadowOffsetY;
  76725. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76726. get shadowOffsetY(): number;
  76727. set shadowOffsetY(value: number);
  76728. private _shadowBlur;
  76729. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76730. get shadowBlur(): number;
  76731. set shadowBlur(value: number);
  76732. private _shadowColor;
  76733. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76734. get shadowColor(): string;
  76735. set shadowColor(value: string);
  76736. /** Gets or sets the cursor to use when the control is hovered */
  76737. hoverCursor: string;
  76738. /** @hidden */
  76739. protected _linkOffsetX: ValueAndUnit;
  76740. /** @hidden */
  76741. protected _linkOffsetY: ValueAndUnit;
  76742. /** Gets the control type name */
  76743. get typeName(): string;
  76744. /**
  76745. * Get the current class name of the control.
  76746. * @returns current class name
  76747. */
  76748. getClassName(): string;
  76749. /**
  76750. * An event triggered when pointer wheel is scrolled
  76751. */
  76752. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76753. /**
  76754. * An event triggered when the pointer move over the control.
  76755. */
  76756. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76757. /**
  76758. * An event triggered when the pointer move out of the control.
  76759. */
  76760. onPointerOutObservable: BABYLON.Observable<Control>;
  76761. /**
  76762. * An event triggered when the pointer taps the control
  76763. */
  76764. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76765. /**
  76766. * An event triggered when pointer up
  76767. */
  76768. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76769. /**
  76770. * An event triggered when a control is clicked on
  76771. */
  76772. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76773. /**
  76774. * An event triggered when pointer enters the control
  76775. */
  76776. onPointerEnterObservable: BABYLON.Observable<Control>;
  76777. /**
  76778. * An event triggered when the control is marked as dirty
  76779. */
  76780. onDirtyObservable: BABYLON.Observable<Control>;
  76781. /**
  76782. * An event triggered before drawing the control
  76783. */
  76784. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76785. /**
  76786. * An event triggered after the control was drawn
  76787. */
  76788. onAfterDrawObservable: BABYLON.Observable<Control>;
  76789. /**
  76790. * An event triggered when the control has been disposed
  76791. */
  76792. onDisposeObservable: BABYLON.Observable<Control>;
  76793. /**
  76794. * Get the hosting AdvancedDynamicTexture
  76795. */
  76796. get host(): AdvancedDynamicTexture;
  76797. /** Gets or set information about font offsets (used to render and align text) */
  76798. get fontOffset(): {
  76799. ascent: number;
  76800. height: number;
  76801. descent: number;
  76802. };
  76803. set fontOffset(offset: {
  76804. ascent: number;
  76805. height: number;
  76806. descent: number;
  76807. });
  76808. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76809. get alpha(): number;
  76810. set alpha(value: number);
  76811. /**
  76812. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76813. */
  76814. get isHighlighted(): boolean;
  76815. set isHighlighted(value: boolean);
  76816. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76817. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76818. */
  76819. get scaleX(): number;
  76820. set scaleX(value: number);
  76821. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76822. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76823. */
  76824. get scaleY(): number;
  76825. set scaleY(value: number);
  76826. /** Gets or sets the rotation angle (0 by default)
  76827. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76828. */
  76829. get rotation(): number;
  76830. set rotation(value: number);
  76831. /** Gets or sets the transformation center on Y axis (0 by default)
  76832. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76833. */
  76834. get transformCenterY(): number;
  76835. set transformCenterY(value: number);
  76836. /** Gets or sets the transformation center on X axis (0 by default)
  76837. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76838. */
  76839. get transformCenterX(): number;
  76840. set transformCenterX(value: number);
  76841. /**
  76842. * Gets or sets the horizontal alignment
  76843. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76844. */
  76845. get horizontalAlignment(): number;
  76846. set horizontalAlignment(value: number);
  76847. /**
  76848. * Gets or sets the vertical alignment
  76849. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76850. */
  76851. get verticalAlignment(): number;
  76852. set verticalAlignment(value: number);
  76853. /**
  76854. * Gets or sets a fixed ratio for this control.
  76855. * When different from 0, the ratio is used to compute the "second" dimension.
  76856. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76857. * second dimension is computed as first dimension * fixedRatio
  76858. */
  76859. fixedRatio: number;
  76860. private _fixedRatioMasterIsWidth;
  76861. /**
  76862. * Gets or sets control width
  76863. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76864. */
  76865. get width(): string | number;
  76866. set width(value: string | number);
  76867. /**
  76868. * Gets or sets the control width in pixel
  76869. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76870. */
  76871. get widthInPixels(): number;
  76872. set widthInPixels(value: number);
  76873. /**
  76874. * Gets or sets control height
  76875. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76876. */
  76877. get height(): string | number;
  76878. set height(value: string | number);
  76879. /**
  76880. * Gets or sets control height in pixel
  76881. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76882. */
  76883. get heightInPixels(): number;
  76884. set heightInPixels(value: number);
  76885. /** Gets or set font family */
  76886. get fontFamily(): string;
  76887. set fontFamily(value: string);
  76888. /** Gets or sets font style */
  76889. get fontStyle(): string;
  76890. set fontStyle(value: string);
  76891. /** Gets or sets font weight */
  76892. get fontWeight(): string;
  76893. set fontWeight(value: string);
  76894. /**
  76895. * Gets or sets style
  76896. * @see https://doc.babylonjs.com/how_to/gui#styles
  76897. */
  76898. get style(): BABYLON.Nullable<Style>;
  76899. set style(value: BABYLON.Nullable<Style>);
  76900. /** @hidden */
  76901. get _isFontSizeInPercentage(): boolean;
  76902. /** Gets or sets font size in pixels */
  76903. get fontSizeInPixels(): number;
  76904. set fontSizeInPixels(value: number);
  76905. /** Gets or sets font size */
  76906. get fontSize(): string | number;
  76907. set fontSize(value: string | number);
  76908. /** Gets or sets foreground color */
  76909. get color(): string;
  76910. set color(value: string);
  76911. /** Gets or sets z index which is used to reorder controls on the z axis */
  76912. get zIndex(): number;
  76913. set zIndex(value: number);
  76914. /** Gets or sets a boolean indicating if the control can be rendered */
  76915. get notRenderable(): boolean;
  76916. set notRenderable(value: boolean);
  76917. /** Gets or sets a boolean indicating if the control is visible */
  76918. get isVisible(): boolean;
  76919. set isVisible(value: boolean);
  76920. /** Gets a boolean indicating that the control needs to update its rendering */
  76921. get isDirty(): boolean;
  76922. /**
  76923. * Gets the current linked mesh (or null if none)
  76924. */
  76925. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76926. /**
  76927. * Gets or sets a value indicating the padding to use on the left of the control
  76928. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76929. */
  76930. get paddingLeft(): string | number;
  76931. set paddingLeft(value: string | number);
  76932. /**
  76933. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76934. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76935. */
  76936. get paddingLeftInPixels(): number;
  76937. set paddingLeftInPixels(value: number);
  76938. /**
  76939. * Gets or sets a value indicating the padding to use on the right of the control
  76940. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76941. */
  76942. get paddingRight(): string | number;
  76943. set paddingRight(value: string | number);
  76944. /**
  76945. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76946. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76947. */
  76948. get paddingRightInPixels(): number;
  76949. set paddingRightInPixels(value: number);
  76950. /**
  76951. * Gets or sets a value indicating the padding to use on the top of the control
  76952. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76953. */
  76954. get paddingTop(): string | number;
  76955. set paddingTop(value: string | number);
  76956. /**
  76957. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76958. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76959. */
  76960. get paddingTopInPixels(): number;
  76961. set paddingTopInPixels(value: number);
  76962. /**
  76963. * Gets or sets a value indicating the padding to use on the bottom of the control
  76964. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76965. */
  76966. get paddingBottom(): string | number;
  76967. set paddingBottom(value: string | number);
  76968. /**
  76969. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76970. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76971. */
  76972. get paddingBottomInPixels(): number;
  76973. set paddingBottomInPixels(value: number);
  76974. /**
  76975. * Gets or sets a value indicating the left coordinate of the control
  76976. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76977. */
  76978. get left(): string | number;
  76979. set left(value: string | number);
  76980. /**
  76981. * Gets or sets a value indicating the left coordinate in pixels of the control
  76982. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76983. */
  76984. get leftInPixels(): number;
  76985. set leftInPixels(value: number);
  76986. /**
  76987. * Gets or sets a value indicating the top coordinate of the control
  76988. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76989. */
  76990. get top(): string | number;
  76991. set top(value: string | number);
  76992. /**
  76993. * Gets or sets a value indicating the top coordinate in pixels of the control
  76994. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76995. */
  76996. get topInPixels(): number;
  76997. set topInPixels(value: number);
  76998. /**
  76999. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77000. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77001. */
  77002. get linkOffsetX(): string | number;
  77003. set linkOffsetX(value: string | number);
  77004. /**
  77005. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77006. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77007. */
  77008. get linkOffsetXInPixels(): number;
  77009. set linkOffsetXInPixels(value: number);
  77010. /**
  77011. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77012. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77013. */
  77014. get linkOffsetY(): string | number;
  77015. set linkOffsetY(value: string | number);
  77016. /**
  77017. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77018. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77019. */
  77020. get linkOffsetYInPixels(): number;
  77021. set linkOffsetYInPixels(value: number);
  77022. /** Gets the center coordinate on X axis */
  77023. get centerX(): number;
  77024. /** Gets the center coordinate on Y axis */
  77025. get centerY(): number;
  77026. /** Gets or sets if control is Enabled*/
  77027. get isEnabled(): boolean;
  77028. set isEnabled(value: boolean);
  77029. /** Gets or sets background color of control if it's disabled*/
  77030. get disabledColor(): string;
  77031. set disabledColor(value: string);
  77032. /** Gets or sets front color of control if it's disabled*/
  77033. get disabledColorItem(): string;
  77034. set disabledColorItem(value: string);
  77035. /**
  77036. * Creates a new control
  77037. * @param name defines the name of the control
  77038. */
  77039. constructor(
  77040. /** defines the name of the control */
  77041. name?: string | undefined);
  77042. /** @hidden */
  77043. protected _getTypeName(): string;
  77044. /**
  77045. * Gets the first ascendant in the hierarchy of the given type
  77046. * @param className defines the required type
  77047. * @returns the ascendant or null if not found
  77048. */
  77049. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77050. /** @hidden */
  77051. _resetFontCache(): void;
  77052. /**
  77053. * Determines if a container is an ascendant of the current control
  77054. * @param container defines the container to look for
  77055. * @returns true if the container is one of the ascendant of the control
  77056. */
  77057. isAscendant(container: Control): boolean;
  77058. /**
  77059. * Gets coordinates in local control space
  77060. * @param globalCoordinates defines the coordinates to transform
  77061. * @returns the new coordinates in local space
  77062. */
  77063. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77064. /**
  77065. * Gets coordinates in local control space
  77066. * @param globalCoordinates defines the coordinates to transform
  77067. * @param result defines the target vector2 where to store the result
  77068. * @returns the current control
  77069. */
  77070. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77071. /**
  77072. * Gets coordinates in parent local control space
  77073. * @param globalCoordinates defines the coordinates to transform
  77074. * @returns the new coordinates in parent local space
  77075. */
  77076. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77077. /**
  77078. * Move the current control to a vector3 position projected onto the screen.
  77079. * @param position defines the target position
  77080. * @param scene defines the hosting scene
  77081. */
  77082. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77083. /**
  77084. * Will store all controls that have this control as ascendant in a given array
  77085. * @param results defines the array where to store the descendants
  77086. * @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
  77087. * @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
  77088. */
  77089. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77090. /**
  77091. * Will return all controls that have this control as ascendant
  77092. * @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
  77093. * @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
  77094. * @return all child controls
  77095. */
  77096. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77097. /**
  77098. * Link current control with a target mesh
  77099. * @param mesh defines the mesh to link with
  77100. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77101. */
  77102. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77103. /** @hidden */
  77104. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77105. /** @hidden */
  77106. _offsetLeft(offset: number): void;
  77107. /** @hidden */
  77108. _offsetTop(offset: number): void;
  77109. /** @hidden */
  77110. _markMatrixAsDirty(): void;
  77111. /** @hidden */
  77112. _flagDescendantsAsMatrixDirty(): void;
  77113. /** @hidden */
  77114. _intersectsRect(rect: Measure): boolean;
  77115. /** @hidden */
  77116. protected invalidateRect(): void;
  77117. /** @hidden */
  77118. _markAsDirty(force?: boolean): void;
  77119. /** @hidden */
  77120. _markAllAsDirty(): void;
  77121. /** @hidden */
  77122. _link(host: AdvancedDynamicTexture): void;
  77123. /** @hidden */
  77124. protected _transform(context?: CanvasRenderingContext2D): void;
  77125. /** @hidden */
  77126. _renderHighlight(context: CanvasRenderingContext2D): void;
  77127. /** @hidden */
  77128. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77129. /** @hidden */
  77130. protected _applyStates(context: CanvasRenderingContext2D): void;
  77131. /** @hidden */
  77132. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77133. /** @hidden */
  77134. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77135. protected _evaluateClippingState(parentMeasure: Measure): void;
  77136. /** @hidden */
  77137. _measure(): void;
  77138. /** @hidden */
  77139. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77140. /** @hidden */
  77141. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77142. /** @hidden */
  77143. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77144. /** @hidden */
  77145. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77146. private static _ClipMeasure;
  77147. private _tmpMeasureA;
  77148. private _clip;
  77149. /** @hidden */
  77150. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77151. /** @hidden */
  77152. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77153. /**
  77154. * Tests if a given coordinates belong to the current control
  77155. * @param x defines x coordinate to test
  77156. * @param y defines y coordinate to test
  77157. * @returns true if the coordinates are inside the control
  77158. */
  77159. contains(x: number, y: number): boolean;
  77160. /** @hidden */
  77161. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77162. /** @hidden */
  77163. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77164. /** @hidden */
  77165. _onPointerEnter(target: Control): boolean;
  77166. /** @hidden */
  77167. _onPointerOut(target: Control, force?: boolean): void;
  77168. /** @hidden */
  77169. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77170. /** @hidden */
  77171. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77172. /** @hidden */
  77173. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77174. /** @hidden */
  77175. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77176. /** @hidden */
  77177. _onCanvasBlur(): void;
  77178. /** @hidden */
  77179. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77180. private _prepareFont;
  77181. /** Releases associated resources */
  77182. dispose(): void;
  77183. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77184. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77185. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77186. private static _VERTICAL_ALIGNMENT_TOP;
  77187. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77188. private static _VERTICAL_ALIGNMENT_CENTER;
  77189. /** HORIZONTAL_ALIGNMENT_LEFT */
  77190. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77191. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77192. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77193. /** HORIZONTAL_ALIGNMENT_CENTER */
  77194. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77195. /** VERTICAL_ALIGNMENT_TOP */
  77196. static get VERTICAL_ALIGNMENT_TOP(): number;
  77197. /** VERTICAL_ALIGNMENT_BOTTOM */
  77198. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77199. /** VERTICAL_ALIGNMENT_CENTER */
  77200. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77201. private static _FontHeightSizes;
  77202. /** @hidden */
  77203. static _GetFontOffset(font: string): {
  77204. ascent: number;
  77205. height: number;
  77206. descent: number;
  77207. };
  77208. /**
  77209. * Creates a stack panel that can be used to render headers
  77210. * @param control defines the control to associate with the header
  77211. * @param text defines the text of the header
  77212. * @param size defines the size of the header
  77213. * @param options defines options used to configure the header
  77214. * @returns a new StackPanel
  77215. * @ignore
  77216. * @hidden
  77217. */
  77218. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77219. isHorizontal: boolean;
  77220. controlFirst: boolean;
  77221. }) => any;
  77222. /** @hidden */
  77223. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77224. }
  77225. }
  77226. declare module BABYLON.GUI {
  77227. /**
  77228. * Root class for 2D containers
  77229. * @see https://doc.babylonjs.com/how_to/gui#containers
  77230. */
  77231. export class Container extends Control {
  77232. name?: string | undefined;
  77233. /** @hidden */
  77234. _children: Control[];
  77235. /** @hidden */
  77236. protected _measureForChildren: Measure;
  77237. /** @hidden */
  77238. protected _background: string;
  77239. /** @hidden */
  77240. protected _adaptWidthToChildren: boolean;
  77241. /** @hidden */
  77242. protected _adaptHeightToChildren: boolean;
  77243. /**
  77244. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77245. */
  77246. logLayoutCycleErrors: boolean;
  77247. /**
  77248. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77249. */
  77250. maxLayoutCycle: number;
  77251. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77252. get adaptHeightToChildren(): boolean;
  77253. set adaptHeightToChildren(value: boolean);
  77254. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77255. get adaptWidthToChildren(): boolean;
  77256. set adaptWidthToChildren(value: boolean);
  77257. /** Gets or sets background color */
  77258. get background(): string;
  77259. set background(value: string);
  77260. /** Gets the list of children */
  77261. get children(): Control[];
  77262. /**
  77263. * Creates a new Container
  77264. * @param name defines the name of the container
  77265. */
  77266. constructor(name?: string | undefined);
  77267. protected _getTypeName(): string;
  77268. _flagDescendantsAsMatrixDirty(): void;
  77269. /**
  77270. * Gets a child using its name
  77271. * @param name defines the child name to look for
  77272. * @returns the child control if found
  77273. */
  77274. getChildByName(name: string): BABYLON.Nullable<Control>;
  77275. /**
  77276. * Gets a child using its type and its name
  77277. * @param name defines the child name to look for
  77278. * @param type defines the child type to look for
  77279. * @returns the child control if found
  77280. */
  77281. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77282. /**
  77283. * Search for a specific control in children
  77284. * @param control defines the control to look for
  77285. * @returns true if the control is in child list
  77286. */
  77287. containsControl(control: Control): boolean;
  77288. /**
  77289. * Adds a new control to the current container
  77290. * @param control defines the control to add
  77291. * @returns the current container
  77292. */
  77293. addControl(control: BABYLON.Nullable<Control>): Container;
  77294. /**
  77295. * Removes all controls from the current container
  77296. * @returns the current container
  77297. */
  77298. clearControls(): Container;
  77299. /**
  77300. * Removes a control from the current container
  77301. * @param control defines the control to remove
  77302. * @returns the current container
  77303. */
  77304. removeControl(control: Control): Container;
  77305. /** @hidden */
  77306. _reOrderControl(control: Control): void;
  77307. /** @hidden */
  77308. _offsetLeft(offset: number): void;
  77309. /** @hidden */
  77310. _offsetTop(offset: number): void;
  77311. /** @hidden */
  77312. _markAllAsDirty(): void;
  77313. /** @hidden */
  77314. protected _localDraw(context: CanvasRenderingContext2D): void;
  77315. /** @hidden */
  77316. _link(host: AdvancedDynamicTexture): void;
  77317. /** @hidden */
  77318. protected _beforeLayout(): void;
  77319. /** @hidden */
  77320. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77321. /** @hidden */
  77322. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77323. protected _postMeasure(): void;
  77324. /** @hidden */
  77325. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77326. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77327. /** @hidden */
  77328. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77329. /** @hidden */
  77330. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77331. /** Releases associated resources */
  77332. dispose(): void;
  77333. }
  77334. }
  77335. declare module BABYLON.GUI {
  77336. /** Class used to create rectangle container */
  77337. export class Rectangle extends Container {
  77338. name?: string | undefined;
  77339. private _thickness;
  77340. private _cornerRadius;
  77341. /** Gets or sets border thickness */
  77342. get thickness(): number;
  77343. set thickness(value: number);
  77344. /** Gets or sets the corner radius angle */
  77345. get cornerRadius(): number;
  77346. set cornerRadius(value: number);
  77347. /**
  77348. * Creates a new Rectangle
  77349. * @param name defines the control name
  77350. */
  77351. constructor(name?: string | undefined);
  77352. protected _getTypeName(): string;
  77353. protected _localDraw(context: CanvasRenderingContext2D): void;
  77354. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77355. private _drawRoundedRect;
  77356. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77357. }
  77358. }
  77359. declare module BABYLON.GUI {
  77360. /**
  77361. * Enum that determines the text-wrapping mode to use.
  77362. */
  77363. export enum TextWrapping {
  77364. /**
  77365. * Clip the text when it's larger than Control.width; this is the default mode.
  77366. */
  77367. Clip = 0,
  77368. /**
  77369. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77370. */
  77371. WordWrap = 1,
  77372. /**
  77373. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77374. */
  77375. Ellipsis = 2
  77376. }
  77377. /**
  77378. * Class used to create text block control
  77379. */
  77380. export class TextBlock extends Control {
  77381. /**
  77382. * Defines the name of the control
  77383. */
  77384. name?: string | undefined;
  77385. private _text;
  77386. private _textWrapping;
  77387. private _textHorizontalAlignment;
  77388. private _textVerticalAlignment;
  77389. private _lines;
  77390. private _resizeToFit;
  77391. private _lineSpacing;
  77392. private _outlineWidth;
  77393. private _outlineColor;
  77394. /**
  77395. * An event triggered after the text is changed
  77396. */
  77397. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77398. /**
  77399. * An event triggered after the text was broken up into lines
  77400. */
  77401. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77402. /**
  77403. * Function used to split a string into words. By default, a string is split at each space character found
  77404. */
  77405. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77406. /**
  77407. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77408. */
  77409. get lines(): any[];
  77410. /**
  77411. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77412. */
  77413. get resizeToFit(): boolean;
  77414. /**
  77415. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77416. */
  77417. set resizeToFit(value: boolean);
  77418. /**
  77419. * Gets or sets a boolean indicating if text must be wrapped
  77420. */
  77421. get textWrapping(): TextWrapping | boolean;
  77422. /**
  77423. * Gets or sets a boolean indicating if text must be wrapped
  77424. */
  77425. set textWrapping(value: TextWrapping | boolean);
  77426. /**
  77427. * Gets or sets text to display
  77428. */
  77429. get text(): string;
  77430. /**
  77431. * Gets or sets text to display
  77432. */
  77433. set text(value: string);
  77434. /**
  77435. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77436. */
  77437. get textHorizontalAlignment(): number;
  77438. /**
  77439. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77440. */
  77441. set textHorizontalAlignment(value: number);
  77442. /**
  77443. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77444. */
  77445. get textVerticalAlignment(): number;
  77446. /**
  77447. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77448. */
  77449. set textVerticalAlignment(value: number);
  77450. /**
  77451. * Gets or sets line spacing value
  77452. */
  77453. set lineSpacing(value: string | number);
  77454. /**
  77455. * Gets or sets line spacing value
  77456. */
  77457. get lineSpacing(): string | number;
  77458. /**
  77459. * Gets or sets outlineWidth of the text to display
  77460. */
  77461. get outlineWidth(): number;
  77462. /**
  77463. * Gets or sets outlineWidth of the text to display
  77464. */
  77465. set outlineWidth(value: number);
  77466. /**
  77467. * Gets or sets outlineColor of the text to display
  77468. */
  77469. get outlineColor(): string;
  77470. /**
  77471. * Gets or sets outlineColor of the text to display
  77472. */
  77473. set outlineColor(value: string);
  77474. /**
  77475. * Creates a new TextBlock object
  77476. * @param name defines the name of the control
  77477. * @param text defines the text to display (emptry string by default)
  77478. */
  77479. constructor(
  77480. /**
  77481. * Defines the name of the control
  77482. */
  77483. name?: string | undefined, text?: string);
  77484. protected _getTypeName(): string;
  77485. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77486. private _drawText;
  77487. /** @hidden */
  77488. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77489. protected _applyStates(context: CanvasRenderingContext2D): void;
  77490. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77491. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77492. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77493. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77494. protected _renderLines(context: CanvasRenderingContext2D): void;
  77495. /**
  77496. * Given a width constraint applied on the text block, find the expected height
  77497. * @returns expected height
  77498. */
  77499. computeExpectedHeight(): number;
  77500. dispose(): void;
  77501. }
  77502. }
  77503. declare module BABYLON.GUI {
  77504. /**
  77505. * Class used to create 2D images
  77506. */
  77507. export class Image extends Control {
  77508. name?: string | undefined;
  77509. private _workingCanvas;
  77510. private _domImage;
  77511. private _imageWidth;
  77512. private _imageHeight;
  77513. private _loaded;
  77514. private _stretch;
  77515. private _source;
  77516. private _autoScale;
  77517. private _sourceLeft;
  77518. private _sourceTop;
  77519. private _sourceWidth;
  77520. private _sourceHeight;
  77521. private _svgAttributesComputationCompleted;
  77522. private _isSVG;
  77523. private _cellWidth;
  77524. private _cellHeight;
  77525. private _cellId;
  77526. private _populateNinePatchSlicesFromImage;
  77527. private _sliceLeft;
  77528. private _sliceRight;
  77529. private _sliceTop;
  77530. private _sliceBottom;
  77531. private _detectPointerOnOpaqueOnly;
  77532. private _imageDataCache;
  77533. /**
  77534. * BABYLON.Observable notified when the content is loaded
  77535. */
  77536. onImageLoadedObservable: BABYLON.Observable<Image>;
  77537. /**
  77538. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77539. */
  77540. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77541. /**
  77542. * Gets a boolean indicating that the content is loaded
  77543. */
  77544. get isLoaded(): boolean;
  77545. /**
  77546. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77547. */
  77548. get populateNinePatchSlicesFromImage(): boolean;
  77549. set populateNinePatchSlicesFromImage(value: boolean);
  77550. /**
  77551. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77552. * Beware using this as this will comsume more memory as the image has to be stored twice
  77553. */
  77554. get detectPointerOnOpaqueOnly(): boolean;
  77555. set detectPointerOnOpaqueOnly(value: boolean);
  77556. /**
  77557. * Gets or sets the left value for slicing (9-patch)
  77558. */
  77559. get sliceLeft(): number;
  77560. set sliceLeft(value: number);
  77561. /**
  77562. * Gets or sets the right value for slicing (9-patch)
  77563. */
  77564. get sliceRight(): number;
  77565. set sliceRight(value: number);
  77566. /**
  77567. * Gets or sets the top value for slicing (9-patch)
  77568. */
  77569. get sliceTop(): number;
  77570. set sliceTop(value: number);
  77571. /**
  77572. * Gets or sets the bottom value for slicing (9-patch)
  77573. */
  77574. get sliceBottom(): number;
  77575. set sliceBottom(value: number);
  77576. /**
  77577. * Gets or sets the left coordinate in the source image
  77578. */
  77579. get sourceLeft(): number;
  77580. set sourceLeft(value: number);
  77581. /**
  77582. * Gets or sets the top coordinate in the source image
  77583. */
  77584. get sourceTop(): number;
  77585. set sourceTop(value: number);
  77586. /**
  77587. * Gets or sets the width to capture in the source image
  77588. */
  77589. get sourceWidth(): number;
  77590. set sourceWidth(value: number);
  77591. /**
  77592. * Gets or sets the height to capture in the source image
  77593. */
  77594. get sourceHeight(): number;
  77595. set sourceHeight(value: number);
  77596. /** Indicates if the format of the image is SVG */
  77597. get isSVG(): boolean;
  77598. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77599. get svgAttributesComputationCompleted(): boolean;
  77600. /**
  77601. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77602. * @see https://doc.babylonjs.com/how_to/gui#image
  77603. */
  77604. get autoScale(): boolean;
  77605. set autoScale(value: boolean);
  77606. /** Gets or sets the streching mode used by the image */
  77607. get stretch(): number;
  77608. set stretch(value: number);
  77609. /** @hidden */
  77610. _rotate90(n: number, preserveProperties?: boolean): Image;
  77611. private _handleRotationForSVGImage;
  77612. private _rotate90SourceProperties;
  77613. /**
  77614. * Gets or sets the internal DOM image used to render the control
  77615. */
  77616. set domImage(value: HTMLImageElement);
  77617. get domImage(): HTMLImageElement;
  77618. private _onImageLoaded;
  77619. private _extractNinePatchSliceDataFromImage;
  77620. /**
  77621. * Gets or sets image source url
  77622. */
  77623. set source(value: BABYLON.Nullable<string>);
  77624. /**
  77625. * Checks for svg document with icon id present
  77626. */
  77627. private _svgCheck;
  77628. /**
  77629. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77630. * given external svg file and icon id
  77631. */
  77632. private _getSVGAttribs;
  77633. /**
  77634. * Gets or sets the cell width to use when animation sheet is enabled
  77635. * @see https://doc.babylonjs.com/how_to/gui#image
  77636. */
  77637. get cellWidth(): number;
  77638. set cellWidth(value: number);
  77639. /**
  77640. * Gets or sets the cell height to use when animation sheet is enabled
  77641. * @see https://doc.babylonjs.com/how_to/gui#image
  77642. */
  77643. get cellHeight(): number;
  77644. set cellHeight(value: number);
  77645. /**
  77646. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77647. * @see https://doc.babylonjs.com/how_to/gui#image
  77648. */
  77649. get cellId(): number;
  77650. set cellId(value: number);
  77651. /**
  77652. * Creates a new Image
  77653. * @param name defines the control name
  77654. * @param url defines the image url
  77655. */
  77656. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77657. /**
  77658. * Tests if a given coordinates belong to the current control
  77659. * @param x defines x coordinate to test
  77660. * @param y defines y coordinate to test
  77661. * @returns true if the coordinates are inside the control
  77662. */
  77663. contains(x: number, y: number): boolean;
  77664. protected _getTypeName(): string;
  77665. /** Force the control to synchronize with its content */
  77666. synchronizeSizeWithContent(): void;
  77667. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77668. private _prepareWorkingCanvasForOpaqueDetection;
  77669. private _drawImage;
  77670. _draw(context: CanvasRenderingContext2D): void;
  77671. private _renderCornerPatch;
  77672. private _renderNinePatch;
  77673. dispose(): void;
  77674. /** STRETCH_NONE */
  77675. static readonly STRETCH_NONE: number;
  77676. /** STRETCH_FILL */
  77677. static readonly STRETCH_FILL: number;
  77678. /** STRETCH_UNIFORM */
  77679. static readonly STRETCH_UNIFORM: number;
  77680. /** STRETCH_EXTEND */
  77681. static readonly STRETCH_EXTEND: number;
  77682. /** NINE_PATCH */
  77683. static readonly STRETCH_NINE_PATCH: number;
  77684. }
  77685. }
  77686. declare module BABYLON.GUI {
  77687. /**
  77688. * Class used to create 2D buttons
  77689. */
  77690. export class Button extends Rectangle {
  77691. name?: string | undefined;
  77692. /**
  77693. * Function called to generate a pointer enter animation
  77694. */
  77695. pointerEnterAnimation: () => void;
  77696. /**
  77697. * Function called to generate a pointer out animation
  77698. */
  77699. pointerOutAnimation: () => void;
  77700. /**
  77701. * Function called to generate a pointer down animation
  77702. */
  77703. pointerDownAnimation: () => void;
  77704. /**
  77705. * Function called to generate a pointer up animation
  77706. */
  77707. pointerUpAnimation: () => void;
  77708. /**
  77709. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77710. */
  77711. delegatePickingToChildren: boolean;
  77712. private _image;
  77713. /**
  77714. * Returns the image part of the button (if any)
  77715. */
  77716. get image(): BABYLON.Nullable<Image>;
  77717. private _textBlock;
  77718. /**
  77719. * Returns the image part of the button (if any)
  77720. */
  77721. get textBlock(): BABYLON.Nullable<TextBlock>;
  77722. /**
  77723. * Creates a new Button
  77724. * @param name defines the name of the button
  77725. */
  77726. constructor(name?: string | undefined);
  77727. protected _getTypeName(): string;
  77728. /** @hidden */
  77729. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77730. /** @hidden */
  77731. _onPointerEnter(target: Control): boolean;
  77732. /** @hidden */
  77733. _onPointerOut(target: Control, force?: boolean): void;
  77734. /** @hidden */
  77735. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77736. /** @hidden */
  77737. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77738. /**
  77739. * Creates a new button made with an image and a text
  77740. * @param name defines the name of the button
  77741. * @param text defines the text of the button
  77742. * @param imageUrl defines the url of the image
  77743. * @returns a new Button
  77744. */
  77745. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77746. /**
  77747. * Creates a new button made with an image
  77748. * @param name defines the name of the button
  77749. * @param imageUrl defines the url of the image
  77750. * @returns a new Button
  77751. */
  77752. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77753. /**
  77754. * Creates a new button made with a text
  77755. * @param name defines the name of the button
  77756. * @param text defines the text of the button
  77757. * @returns a new Button
  77758. */
  77759. static CreateSimpleButton(name: string, text: string): Button;
  77760. /**
  77761. * Creates a new button made with an image and a centered text
  77762. * @param name defines the name of the button
  77763. * @param text defines the text of the button
  77764. * @param imageUrl defines the url of the image
  77765. * @returns a new Button
  77766. */
  77767. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77768. }
  77769. }
  77770. declare module BABYLON.GUI {
  77771. /**
  77772. * Class used to create a 2D stack panel container
  77773. */
  77774. export class StackPanel extends Container {
  77775. name?: string | undefined;
  77776. private _isVertical;
  77777. private _manualWidth;
  77778. private _manualHeight;
  77779. private _doNotTrackManualChanges;
  77780. /**
  77781. * Gets or sets a boolean indicating that layou warnings should be ignored
  77782. */
  77783. ignoreLayoutWarnings: boolean;
  77784. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77785. get isVertical(): boolean;
  77786. set isVertical(value: boolean);
  77787. /**
  77788. * Gets or sets panel width.
  77789. * This value should not be set when in horizontal mode as it will be computed automatically
  77790. */
  77791. set width(value: string | number);
  77792. get width(): string | number;
  77793. /**
  77794. * Gets or sets panel height.
  77795. * This value should not be set when in vertical mode as it will be computed automatically
  77796. */
  77797. set height(value: string | number);
  77798. get height(): string | number;
  77799. /**
  77800. * Creates a new StackPanel
  77801. * @param name defines control name
  77802. */
  77803. constructor(name?: string | undefined);
  77804. protected _getTypeName(): string;
  77805. /** @hidden */
  77806. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77807. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77808. protected _postMeasure(): void;
  77809. }
  77810. }
  77811. declare module BABYLON.GUI {
  77812. /**
  77813. * Class used to represent a 2D checkbox
  77814. */
  77815. export class Checkbox extends Control {
  77816. name?: string | undefined;
  77817. private _isChecked;
  77818. private _background;
  77819. private _checkSizeRatio;
  77820. private _thickness;
  77821. /** Gets or sets border thickness */
  77822. get thickness(): number;
  77823. set thickness(value: number);
  77824. /**
  77825. * BABYLON.Observable raised when isChecked property changes
  77826. */
  77827. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77828. /** Gets or sets a value indicating the ratio between overall size and check size */
  77829. get checkSizeRatio(): number;
  77830. set checkSizeRatio(value: number);
  77831. /** Gets or sets background color */
  77832. get background(): string;
  77833. set background(value: string);
  77834. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77835. get isChecked(): boolean;
  77836. set isChecked(value: boolean);
  77837. /**
  77838. * Creates a new CheckBox
  77839. * @param name defines the control name
  77840. */
  77841. constructor(name?: string | undefined);
  77842. protected _getTypeName(): string;
  77843. /** @hidden */
  77844. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77845. /** @hidden */
  77846. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77847. /**
  77848. * Utility function to easily create a checkbox with a header
  77849. * @param title defines the label to use for the header
  77850. * @param onValueChanged defines the callback to call when value changes
  77851. * @returns a StackPanel containing the checkbox and a textBlock
  77852. */
  77853. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77854. }
  77855. }
  77856. declare module BABYLON.GUI {
  77857. /**
  77858. * Class used to store key control properties
  77859. */
  77860. export class KeyPropertySet {
  77861. /** Width */
  77862. width?: string;
  77863. /** Height */
  77864. height?: string;
  77865. /** Left padding */
  77866. paddingLeft?: string;
  77867. /** Right padding */
  77868. paddingRight?: string;
  77869. /** Top padding */
  77870. paddingTop?: string;
  77871. /** Bottom padding */
  77872. paddingBottom?: string;
  77873. /** Foreground color */
  77874. color?: string;
  77875. /** Background color */
  77876. background?: string;
  77877. }
  77878. /**
  77879. * Class used to create virtual keyboard
  77880. */
  77881. export class VirtualKeyboard extends StackPanel {
  77882. /** BABYLON.Observable raised when a key is pressed */
  77883. onKeyPressObservable: BABYLON.Observable<string>;
  77884. /** Gets or sets default key button width */
  77885. defaultButtonWidth: string;
  77886. /** Gets or sets default key button height */
  77887. defaultButtonHeight: string;
  77888. /** Gets or sets default key button left padding */
  77889. defaultButtonPaddingLeft: string;
  77890. /** Gets or sets default key button right padding */
  77891. defaultButtonPaddingRight: string;
  77892. /** Gets or sets default key button top padding */
  77893. defaultButtonPaddingTop: string;
  77894. /** Gets or sets default key button bottom padding */
  77895. defaultButtonPaddingBottom: string;
  77896. /** Gets or sets default key button foreground color */
  77897. defaultButtonColor: string;
  77898. /** Gets or sets default key button background color */
  77899. defaultButtonBackground: string;
  77900. /** Gets or sets shift button foreground color */
  77901. shiftButtonColor: string;
  77902. /** Gets or sets shift button thickness*/
  77903. selectedShiftThickness: number;
  77904. /** Gets shift key state */
  77905. shiftState: number;
  77906. protected _getTypeName(): string;
  77907. private _createKey;
  77908. /**
  77909. * Adds a new row of keys
  77910. * @param keys defines the list of keys to add
  77911. * @param propertySets defines the associated property sets
  77912. */
  77913. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77914. /**
  77915. * Set the shift key to a specific state
  77916. * @param shiftState defines the new shift state
  77917. */
  77918. applyShiftState(shiftState: number): void;
  77919. private _currentlyConnectedInputText;
  77920. private _connectedInputTexts;
  77921. private _onKeyPressObserver;
  77922. /** Gets the input text control currently attached to the keyboard */
  77923. get connectedInputText(): BABYLON.Nullable<InputText>;
  77924. /**
  77925. * Connects the keyboard with an input text control
  77926. *
  77927. * @param input defines the target control
  77928. */
  77929. connect(input: InputText): void;
  77930. /**
  77931. * Disconnects the keyboard from connected InputText controls
  77932. *
  77933. * @param input optionally defines a target control, otherwise all are disconnected
  77934. */
  77935. disconnect(input?: InputText): void;
  77936. private _removeConnectedInputObservables;
  77937. /**
  77938. * Release all resources
  77939. */
  77940. dispose(): void;
  77941. /**
  77942. * Creates a new keyboard using a default layout
  77943. *
  77944. * @param name defines control name
  77945. * @returns a new VirtualKeyboard
  77946. */
  77947. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77948. }
  77949. }
  77950. declare module BABYLON.GUI {
  77951. /**
  77952. * Class used to create input text control
  77953. */
  77954. export class InputText extends Control implements IFocusableControl {
  77955. name?: string | undefined;
  77956. private _text;
  77957. private _placeholderText;
  77958. private _background;
  77959. private _focusedBackground;
  77960. private _focusedColor;
  77961. private _placeholderColor;
  77962. private _thickness;
  77963. private _margin;
  77964. private _autoStretchWidth;
  77965. private _maxWidth;
  77966. private _isFocused;
  77967. private _blinkTimeout;
  77968. private _blinkIsEven;
  77969. private _cursorOffset;
  77970. private _scrollLeft;
  77971. private _textWidth;
  77972. private _clickedCoordinate;
  77973. private _deadKey;
  77974. private _addKey;
  77975. private _currentKey;
  77976. private _isTextHighlightOn;
  77977. private _textHighlightColor;
  77978. private _highligherOpacity;
  77979. private _highlightedText;
  77980. private _startHighlightIndex;
  77981. private _endHighlightIndex;
  77982. private _cursorIndex;
  77983. private _onFocusSelectAll;
  77984. private _isPointerDown;
  77985. private _onClipboardObserver;
  77986. private _onPointerDblTapObserver;
  77987. /** @hidden */
  77988. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77989. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77990. promptMessage: string;
  77991. /** Force disable prompt on mobile device */
  77992. disableMobilePrompt: boolean;
  77993. /** BABYLON.Observable raised when the text changes */
  77994. onTextChangedObservable: BABYLON.Observable<InputText>;
  77995. /** BABYLON.Observable raised just before an entered character is to be added */
  77996. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77997. /** BABYLON.Observable raised when the control gets the focus */
  77998. onFocusObservable: BABYLON.Observable<InputText>;
  77999. /** BABYLON.Observable raised when the control loses the focus */
  78000. onBlurObservable: BABYLON.Observable<InputText>;
  78001. /**Observable raised when the text is highlighted */
  78002. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78003. /**Observable raised when copy event is triggered */
  78004. onTextCopyObservable: BABYLON.Observable<InputText>;
  78005. /** BABYLON.Observable raised when cut event is triggered */
  78006. onTextCutObservable: BABYLON.Observable<InputText>;
  78007. /** BABYLON.Observable raised when paste event is triggered */
  78008. onTextPasteObservable: BABYLON.Observable<InputText>;
  78009. /** BABYLON.Observable raised when a key event was processed */
  78010. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78011. /** Gets or sets the maximum width allowed by the control */
  78012. get maxWidth(): string | number;
  78013. /** Gets the maximum width allowed by the control in pixels */
  78014. get maxWidthInPixels(): number;
  78015. set maxWidth(value: string | number);
  78016. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78017. get highligherOpacity(): number;
  78018. set highligherOpacity(value: number);
  78019. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78020. get onFocusSelectAll(): boolean;
  78021. set onFocusSelectAll(value: boolean);
  78022. /** Gets or sets the text hightlight color */
  78023. get textHighlightColor(): string;
  78024. set textHighlightColor(value: string);
  78025. /** Gets or sets control margin */
  78026. get margin(): string;
  78027. /** Gets control margin in pixels */
  78028. get marginInPixels(): number;
  78029. set margin(value: string);
  78030. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78031. get autoStretchWidth(): boolean;
  78032. set autoStretchWidth(value: boolean);
  78033. /** Gets or sets border thickness */
  78034. get thickness(): number;
  78035. set thickness(value: number);
  78036. /** Gets or sets the background color when focused */
  78037. get focusedBackground(): string;
  78038. set focusedBackground(value: string);
  78039. /** Gets or sets the background color when focused */
  78040. get focusedColor(): string;
  78041. set focusedColor(value: string);
  78042. /** Gets or sets the background color */
  78043. get background(): string;
  78044. set background(value: string);
  78045. /** Gets or sets the placeholder color */
  78046. get placeholderColor(): string;
  78047. set placeholderColor(value: string);
  78048. /** Gets or sets the text displayed when the control is empty */
  78049. get placeholderText(): string;
  78050. set placeholderText(value: string);
  78051. /** Gets or sets the dead key flag */
  78052. get deadKey(): boolean;
  78053. set deadKey(flag: boolean);
  78054. /** Gets or sets the highlight text */
  78055. get highlightedText(): string;
  78056. set highlightedText(text: string);
  78057. /** Gets or sets if the current key should be added */
  78058. get addKey(): boolean;
  78059. set addKey(flag: boolean);
  78060. /** Gets or sets the value of the current key being entered */
  78061. get currentKey(): string;
  78062. set currentKey(key: string);
  78063. /** Gets or sets the text displayed in the control */
  78064. get text(): string;
  78065. set text(value: string);
  78066. /** Gets or sets control width */
  78067. get width(): string | number;
  78068. set width(value: string | number);
  78069. /**
  78070. * Creates a new InputText
  78071. * @param name defines the control name
  78072. * @param text defines the text of the control
  78073. */
  78074. constructor(name?: string | undefined, text?: string);
  78075. /** @hidden */
  78076. onBlur(): void;
  78077. /** @hidden */
  78078. onFocus(): void;
  78079. protected _getTypeName(): string;
  78080. /**
  78081. * Function called to get the list of controls that should not steal the focus from this control
  78082. * @returns an array of controls
  78083. */
  78084. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78085. /** @hidden */
  78086. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78087. /** @hidden */
  78088. private _updateValueFromCursorIndex;
  78089. /** @hidden */
  78090. private _processDblClick;
  78091. /** @hidden */
  78092. private _selectAllText;
  78093. /**
  78094. * Handles the keyboard event
  78095. * @param evt Defines the KeyboardEvent
  78096. */
  78097. processKeyboard(evt: KeyboardEvent): void;
  78098. /** @hidden */
  78099. private _onCopyText;
  78100. /** @hidden */
  78101. private _onCutText;
  78102. /** @hidden */
  78103. private _onPasteText;
  78104. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78105. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78106. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78107. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78108. protected _beforeRenderText(text: string): string;
  78109. dispose(): void;
  78110. }
  78111. }
  78112. declare module BABYLON.GUI {
  78113. /**
  78114. * Class used to create a 2D grid container
  78115. */
  78116. export class Grid extends Container {
  78117. name?: string | undefined;
  78118. private _rowDefinitions;
  78119. private _columnDefinitions;
  78120. private _cells;
  78121. private _childControls;
  78122. /**
  78123. * Gets the number of columns
  78124. */
  78125. get columnCount(): number;
  78126. /**
  78127. * Gets the number of rows
  78128. */
  78129. get rowCount(): number;
  78130. /** Gets the list of children */
  78131. get children(): Control[];
  78132. /** Gets the list of cells (e.g. the containers) */
  78133. get cells(): {
  78134. [key: string]: Container;
  78135. };
  78136. /**
  78137. * Gets the definition of a specific row
  78138. * @param index defines the index of the row
  78139. * @returns the row definition
  78140. */
  78141. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78142. /**
  78143. * Gets the definition of a specific column
  78144. * @param index defines the index of the column
  78145. * @returns the column definition
  78146. */
  78147. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78148. /**
  78149. * Adds a new row to the grid
  78150. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78151. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78152. * @returns the current grid
  78153. */
  78154. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78155. /**
  78156. * Adds a new column to the grid
  78157. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78158. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78159. * @returns the current grid
  78160. */
  78161. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78162. /**
  78163. * Update a row definition
  78164. * @param index defines the index of the row to update
  78165. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78166. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78167. * @returns the current grid
  78168. */
  78169. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78170. /**
  78171. * Update a column definition
  78172. * @param index defines the index of the column to update
  78173. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78174. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78175. * @returns the current grid
  78176. */
  78177. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78178. /**
  78179. * Gets the list of children stored in a specific cell
  78180. * @param row defines the row to check
  78181. * @param column defines the column to check
  78182. * @returns the list of controls
  78183. */
  78184. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78185. /**
  78186. * Gets a string representing the child cell info (row x column)
  78187. * @param child defines the control to get info from
  78188. * @returns a string containing the child cell info (row x column)
  78189. */
  78190. getChildCellInfo(child: Control): string;
  78191. private _removeCell;
  78192. private _offsetCell;
  78193. /**
  78194. * Remove a column definition at specified index
  78195. * @param index defines the index of the column to remove
  78196. * @returns the current grid
  78197. */
  78198. removeColumnDefinition(index: number): Grid;
  78199. /**
  78200. * Remove a row definition at specified index
  78201. * @param index defines the index of the row to remove
  78202. * @returns the current grid
  78203. */
  78204. removeRowDefinition(index: number): Grid;
  78205. /**
  78206. * Adds a new control to the current grid
  78207. * @param control defines the control to add
  78208. * @param row defines the row where to add the control (0 by default)
  78209. * @param column defines the column where to add the control (0 by default)
  78210. * @returns the current grid
  78211. */
  78212. addControl(control: Control, row?: number, column?: number): Grid;
  78213. /**
  78214. * Removes a control from the current container
  78215. * @param control defines the control to remove
  78216. * @returns the current container
  78217. */
  78218. removeControl(control: Control): Container;
  78219. /**
  78220. * Creates a new Grid
  78221. * @param name defines control name
  78222. */
  78223. constructor(name?: string | undefined);
  78224. protected _getTypeName(): string;
  78225. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78226. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78227. _flagDescendantsAsMatrixDirty(): void;
  78228. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78229. /** Releases associated resources */
  78230. dispose(): void;
  78231. }
  78232. }
  78233. declare module BABYLON.GUI {
  78234. /** Class used to create color pickers */
  78235. export class ColorPicker extends Control {
  78236. name?: string | undefined;
  78237. private static _Epsilon;
  78238. private _colorWheelCanvas;
  78239. private _value;
  78240. private _tmpColor;
  78241. private _pointerStartedOnSquare;
  78242. private _pointerStartedOnWheel;
  78243. private _squareLeft;
  78244. private _squareTop;
  78245. private _squareSize;
  78246. private _h;
  78247. private _s;
  78248. private _v;
  78249. private _lastPointerDownID;
  78250. /**
  78251. * BABYLON.Observable raised when the value changes
  78252. */
  78253. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78254. /** Gets or sets the color of the color picker */
  78255. get value(): BABYLON.Color3;
  78256. set value(value: BABYLON.Color3);
  78257. /**
  78258. * Gets or sets control width
  78259. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78260. */
  78261. get width(): string | number;
  78262. set width(value: string | number);
  78263. /**
  78264. * Gets or sets control height
  78265. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78266. */
  78267. get height(): string | number;
  78268. /** Gets or sets control height */
  78269. set height(value: string | number);
  78270. /** Gets or sets control size */
  78271. get size(): string | number;
  78272. set size(value: string | number);
  78273. /**
  78274. * Creates a new ColorPicker
  78275. * @param name defines the control name
  78276. */
  78277. constructor(name?: string | undefined);
  78278. protected _getTypeName(): string;
  78279. /** @hidden */
  78280. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78281. private _updateSquareProps;
  78282. private _drawGradientSquare;
  78283. private _drawCircle;
  78284. private _createColorWheelCanvas;
  78285. /** @hidden */
  78286. _draw(context: CanvasRenderingContext2D): void;
  78287. private _pointerIsDown;
  78288. private _updateValueFromPointer;
  78289. private _isPointOnSquare;
  78290. private _isPointOnWheel;
  78291. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78292. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78293. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78294. _onCanvasBlur(): void;
  78295. /**
  78296. * This function expands the color picker by creating a color picker dialog with manual
  78297. * color value input and the ability to save colors into an array to be used later in
  78298. * subsequent launches of the dialogue.
  78299. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78300. * @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.
  78301. * @returns picked color as a hex string and the saved colors array as hex strings.
  78302. */
  78303. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78304. pickerWidth?: string;
  78305. pickerHeight?: string;
  78306. headerHeight?: string;
  78307. lastColor?: string;
  78308. swatchLimit?: number;
  78309. numSwatchesPerLine?: number;
  78310. savedColors?: Array<string>;
  78311. }): Promise<{
  78312. savedColors?: string[];
  78313. pickedColor: string;
  78314. }>;
  78315. }
  78316. }
  78317. declare module BABYLON.GUI {
  78318. /** Class used to create 2D ellipse containers */
  78319. export class Ellipse extends Container {
  78320. name?: string | undefined;
  78321. private _thickness;
  78322. /** Gets or sets border thickness */
  78323. get thickness(): number;
  78324. set thickness(value: number);
  78325. /**
  78326. * Creates a new Ellipse
  78327. * @param name defines the control name
  78328. */
  78329. constructor(name?: string | undefined);
  78330. protected _getTypeName(): string;
  78331. protected _localDraw(context: CanvasRenderingContext2D): void;
  78332. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78333. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78334. }
  78335. }
  78336. declare module BABYLON.GUI {
  78337. /**
  78338. * Class used to create a password control
  78339. */
  78340. export class InputPassword extends InputText {
  78341. protected _beforeRenderText(text: string): string;
  78342. }
  78343. }
  78344. declare module BABYLON.GUI {
  78345. /** Class used to render 2D lines */
  78346. export class Line extends Control {
  78347. name?: string | undefined;
  78348. private _lineWidth;
  78349. private _x1;
  78350. private _y1;
  78351. private _x2;
  78352. private _y2;
  78353. private _dash;
  78354. private _connectedControl;
  78355. private _connectedControlDirtyObserver;
  78356. /** Gets or sets the dash pattern */
  78357. get dash(): Array<number>;
  78358. set dash(value: Array<number>);
  78359. /** Gets or sets the control connected with the line end */
  78360. get connectedControl(): Control;
  78361. set connectedControl(value: Control);
  78362. /** Gets or sets start coordinates on X axis */
  78363. get x1(): string | number;
  78364. set x1(value: string | number);
  78365. /** Gets or sets start coordinates on Y axis */
  78366. get y1(): string | number;
  78367. set y1(value: string | number);
  78368. /** Gets or sets end coordinates on X axis */
  78369. get x2(): string | number;
  78370. set x2(value: string | number);
  78371. /** Gets or sets end coordinates on Y axis */
  78372. get y2(): string | number;
  78373. set y2(value: string | number);
  78374. /** Gets or sets line width */
  78375. get lineWidth(): number;
  78376. set lineWidth(value: number);
  78377. /** Gets or sets horizontal alignment */
  78378. set horizontalAlignment(value: number);
  78379. /** Gets or sets vertical alignment */
  78380. set verticalAlignment(value: number);
  78381. private get _effectiveX2();
  78382. private get _effectiveY2();
  78383. /**
  78384. * Creates a new Line
  78385. * @param name defines the control name
  78386. */
  78387. constructor(name?: string | undefined);
  78388. protected _getTypeName(): string;
  78389. _draw(context: CanvasRenderingContext2D): void;
  78390. _measure(): void;
  78391. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78392. /**
  78393. * Move one end of the line given 3D cartesian coordinates.
  78394. * @param position Targeted world position
  78395. * @param scene BABYLON.Scene
  78396. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78397. */
  78398. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78399. /**
  78400. * Move one end of the line to a position in screen absolute space.
  78401. * @param projectedPosition Position in screen absolute space (X, Y)
  78402. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78403. */
  78404. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78405. }
  78406. }
  78407. declare module BABYLON.GUI {
  78408. /**
  78409. * Class used to store a point for a MultiLine object.
  78410. * The point can be pure 2D coordinates, a mesh or a control
  78411. */
  78412. export class MultiLinePoint {
  78413. private _multiLine;
  78414. private _x;
  78415. private _y;
  78416. private _control;
  78417. private _mesh;
  78418. private _controlObserver;
  78419. private _meshObserver;
  78420. /** @hidden */
  78421. _point: BABYLON.Vector2;
  78422. /**
  78423. * Creates a new MultiLinePoint
  78424. * @param multiLine defines the source MultiLine object
  78425. */
  78426. constructor(multiLine: MultiLine);
  78427. /** Gets or sets x coordinate */
  78428. get x(): string | number;
  78429. set x(value: string | number);
  78430. /** Gets or sets y coordinate */
  78431. get y(): string | number;
  78432. set y(value: string | number);
  78433. /** Gets or sets the control associated with this point */
  78434. get control(): BABYLON.Nullable<Control>;
  78435. set control(value: BABYLON.Nullable<Control>);
  78436. /** Gets or sets the mesh associated with this point */
  78437. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78438. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78439. /** Resets links */
  78440. resetLinks(): void;
  78441. /**
  78442. * Gets a translation vector
  78443. * @returns the translation vector
  78444. */
  78445. translate(): BABYLON.Vector2;
  78446. private _translatePoint;
  78447. /** Release associated resources */
  78448. dispose(): void;
  78449. }
  78450. }
  78451. declare module BABYLON.GUI {
  78452. /**
  78453. * Class used to create multi line control
  78454. */
  78455. export class MultiLine extends Control {
  78456. name?: string | undefined;
  78457. private _lineWidth;
  78458. private _dash;
  78459. private _points;
  78460. private _minX;
  78461. private _minY;
  78462. private _maxX;
  78463. private _maxY;
  78464. /**
  78465. * Creates a new MultiLine
  78466. * @param name defines the control name
  78467. */
  78468. constructor(name?: string | undefined);
  78469. /** Gets or sets dash pattern */
  78470. get dash(): Array<number>;
  78471. set dash(value: Array<number>);
  78472. /**
  78473. * Gets point stored at specified index
  78474. * @param index defines the index to look for
  78475. * @returns the requested point if found
  78476. */
  78477. getAt(index: number): MultiLinePoint;
  78478. /** Function called when a point is updated */
  78479. onPointUpdate: () => void;
  78480. /**
  78481. * Adds new points to the point collection
  78482. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78483. * @returns the list of created MultiLinePoint
  78484. */
  78485. add(...items: (AbstractMesh | Control | {
  78486. x: string | number;
  78487. y: string | number;
  78488. })[]): MultiLinePoint[];
  78489. /**
  78490. * Adds a new point to the point collection
  78491. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78492. * @returns the created MultiLinePoint
  78493. */
  78494. push(item?: (AbstractMesh | Control | {
  78495. x: string | number;
  78496. y: string | number;
  78497. })): MultiLinePoint;
  78498. /**
  78499. * Remove a specific value or point from the active point collection
  78500. * @param value defines the value or point to remove
  78501. */
  78502. remove(value: number | MultiLinePoint): void;
  78503. /**
  78504. * Resets this object to initial state (no point)
  78505. */
  78506. reset(): void;
  78507. /**
  78508. * Resets all links
  78509. */
  78510. resetLinks(): void;
  78511. /** Gets or sets line width */
  78512. get lineWidth(): number;
  78513. set lineWidth(value: number);
  78514. set horizontalAlignment(value: number);
  78515. set verticalAlignment(value: number);
  78516. protected _getTypeName(): string;
  78517. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78518. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78519. _measure(): void;
  78520. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78521. dispose(): void;
  78522. }
  78523. }
  78524. declare module BABYLON.GUI {
  78525. /**
  78526. * Class used to create radio button controls
  78527. */
  78528. export class RadioButton extends Control {
  78529. name?: string | undefined;
  78530. private _isChecked;
  78531. private _background;
  78532. private _checkSizeRatio;
  78533. private _thickness;
  78534. /** Gets or sets border thickness */
  78535. get thickness(): number;
  78536. set thickness(value: number);
  78537. /** Gets or sets group name */
  78538. group: string;
  78539. /** BABYLON.Observable raised when isChecked is changed */
  78540. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78541. /** Gets or sets a value indicating the ratio between overall size and check size */
  78542. get checkSizeRatio(): number;
  78543. set checkSizeRatio(value: number);
  78544. /** Gets or sets background color */
  78545. get background(): string;
  78546. set background(value: string);
  78547. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78548. get isChecked(): boolean;
  78549. set isChecked(value: boolean);
  78550. /**
  78551. * Creates a new RadioButton
  78552. * @param name defines the control name
  78553. */
  78554. constructor(name?: string | undefined);
  78555. protected _getTypeName(): string;
  78556. _draw(context: CanvasRenderingContext2D): void;
  78557. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78558. /**
  78559. * Utility function to easily create a radio button with a header
  78560. * @param title defines the label to use for the header
  78561. * @param group defines the group to use for the radio button
  78562. * @param isChecked defines the initial state of the radio button
  78563. * @param onValueChanged defines the callback to call when value changes
  78564. * @returns a StackPanel containing the radio button and a textBlock
  78565. */
  78566. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78567. }
  78568. }
  78569. declare module BABYLON.GUI {
  78570. /**
  78571. * Class used to create slider controls
  78572. */
  78573. export class BaseSlider extends Control {
  78574. name?: string | undefined;
  78575. protected _thumbWidth: ValueAndUnit;
  78576. private _minimum;
  78577. private _maximum;
  78578. private _value;
  78579. private _isVertical;
  78580. protected _barOffset: ValueAndUnit;
  78581. private _isThumbClamped;
  78582. protected _displayThumb: boolean;
  78583. private _step;
  78584. private _lastPointerDownID;
  78585. protected _effectiveBarOffset: number;
  78586. protected _renderLeft: number;
  78587. protected _renderTop: number;
  78588. protected _renderWidth: number;
  78589. protected _renderHeight: number;
  78590. protected _backgroundBoxLength: number;
  78591. protected _backgroundBoxThickness: number;
  78592. protected _effectiveThumbThickness: number;
  78593. /** BABYLON.Observable raised when the sldier value changes */
  78594. onValueChangedObservable: BABYLON.Observable<number>;
  78595. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78596. get displayThumb(): boolean;
  78597. set displayThumb(value: boolean);
  78598. /** Gets or sets a step to apply to values (0 by default) */
  78599. get step(): number;
  78600. set step(value: number);
  78601. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78602. get barOffset(): string | number;
  78603. /** Gets main bar offset in pixels*/
  78604. get barOffsetInPixels(): number;
  78605. set barOffset(value: string | number);
  78606. /** Gets or sets thumb width */
  78607. get thumbWidth(): string | number;
  78608. /** Gets thumb width in pixels */
  78609. get thumbWidthInPixels(): number;
  78610. set thumbWidth(value: string | number);
  78611. /** Gets or sets minimum value */
  78612. get minimum(): number;
  78613. set minimum(value: number);
  78614. /** Gets or sets maximum value */
  78615. get maximum(): number;
  78616. set maximum(value: number);
  78617. /** Gets or sets current value */
  78618. get value(): number;
  78619. set value(value: number);
  78620. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78621. get isVertical(): boolean;
  78622. set isVertical(value: boolean);
  78623. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78624. get isThumbClamped(): boolean;
  78625. set isThumbClamped(value: boolean);
  78626. /**
  78627. * Creates a new BaseSlider
  78628. * @param name defines the control name
  78629. */
  78630. constructor(name?: string | undefined);
  78631. protected _getTypeName(): string;
  78632. protected _getThumbPosition(): number;
  78633. protected _getThumbThickness(type: string): number;
  78634. protected _prepareRenderingData(type: string): void;
  78635. private _pointerIsDown;
  78636. /** @hidden */
  78637. protected _updateValueFromPointer(x: number, y: number): void;
  78638. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78639. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78640. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78641. _onCanvasBlur(): void;
  78642. }
  78643. }
  78644. declare module BABYLON.GUI {
  78645. /**
  78646. * Class used to create slider controls
  78647. */
  78648. export class Slider extends BaseSlider {
  78649. name?: string | undefined;
  78650. private _background;
  78651. private _borderColor;
  78652. private _isThumbCircle;
  78653. protected _displayValueBar: boolean;
  78654. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78655. get displayValueBar(): boolean;
  78656. set displayValueBar(value: boolean);
  78657. /** Gets or sets border color */
  78658. get borderColor(): string;
  78659. set borderColor(value: string);
  78660. /** Gets or sets background color */
  78661. get background(): string;
  78662. set background(value: string);
  78663. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78664. get isThumbCircle(): boolean;
  78665. set isThumbCircle(value: boolean);
  78666. /**
  78667. * Creates a new Slider
  78668. * @param name defines the control name
  78669. */
  78670. constructor(name?: string | undefined);
  78671. protected _getTypeName(): string;
  78672. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78673. }
  78674. }
  78675. declare module BABYLON.GUI {
  78676. /** Class used to create a RadioGroup
  78677. * which contains groups of radio buttons
  78678. */
  78679. export class SelectorGroup {
  78680. /** name of SelectorGroup */
  78681. name: string;
  78682. private _groupPanel;
  78683. private _selectors;
  78684. private _groupHeader;
  78685. /**
  78686. * Creates a new SelectorGroup
  78687. * @param name of group, used as a group heading
  78688. */
  78689. constructor(
  78690. /** name of SelectorGroup */
  78691. name: string);
  78692. /** Gets the groupPanel of the SelectorGroup */
  78693. get groupPanel(): StackPanel;
  78694. /** Gets the selectors array */
  78695. get selectors(): StackPanel[];
  78696. /** Gets and sets the group header */
  78697. get header(): string;
  78698. set header(label: string);
  78699. /** @hidden */
  78700. private _addGroupHeader;
  78701. /** @hidden*/
  78702. _getSelector(selectorNb: number): StackPanel | undefined;
  78703. /** Removes the selector at the given position
  78704. * @param selectorNb the position of the selector within the group
  78705. */
  78706. removeSelector(selectorNb: number): void;
  78707. }
  78708. /** Class used to create a CheckboxGroup
  78709. * which contains groups of checkbox buttons
  78710. */
  78711. export class CheckboxGroup extends SelectorGroup {
  78712. /** Adds a checkbox as a control
  78713. * @param text is the label for the selector
  78714. * @param func is the function called when the Selector is checked
  78715. * @param checked is true when Selector is checked
  78716. */
  78717. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78718. /** @hidden */
  78719. _setSelectorLabel(selectorNb: number, label: string): void;
  78720. /** @hidden */
  78721. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78722. /** @hidden */
  78723. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78724. /** @hidden */
  78725. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78726. }
  78727. /** Class used to create a RadioGroup
  78728. * which contains groups of radio buttons
  78729. */
  78730. export class RadioGroup extends SelectorGroup {
  78731. private _selectNb;
  78732. /** Adds a radio button as a control
  78733. * @param label is the label for the selector
  78734. * @param func is the function called when the Selector is checked
  78735. * @param checked is true when Selector is checked
  78736. */
  78737. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78738. /** @hidden */
  78739. _setSelectorLabel(selectorNb: number, label: string): void;
  78740. /** @hidden */
  78741. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78742. /** @hidden */
  78743. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78744. /** @hidden */
  78745. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78746. }
  78747. /** Class used to create a SliderGroup
  78748. * which contains groups of slider buttons
  78749. */
  78750. export class SliderGroup extends SelectorGroup {
  78751. /**
  78752. * Adds a slider to the SelectorGroup
  78753. * @param label is the label for the SliderBar
  78754. * @param func is the function called when the Slider moves
  78755. * @param unit is a string describing the units used, eg degrees or metres
  78756. * @param min is the minimum value for the Slider
  78757. * @param max is the maximum value for the Slider
  78758. * @param value is the start value for the Slider between min and max
  78759. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78760. */
  78761. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78762. /** @hidden */
  78763. _setSelectorLabel(selectorNb: number, label: string): void;
  78764. /** @hidden */
  78765. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78766. /** @hidden */
  78767. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78768. /** @hidden */
  78769. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78770. }
  78771. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78772. * @see https://doc.babylonjs.com/how_to/selector
  78773. */
  78774. export class SelectionPanel extends Rectangle {
  78775. /** name of SelectionPanel */
  78776. name: string;
  78777. /** an array of SelectionGroups */
  78778. groups: SelectorGroup[];
  78779. private _panel;
  78780. private _buttonColor;
  78781. private _buttonBackground;
  78782. private _headerColor;
  78783. private _barColor;
  78784. private _barHeight;
  78785. private _spacerHeight;
  78786. private _labelColor;
  78787. private _groups;
  78788. private _bars;
  78789. /**
  78790. * Creates a new SelectionPanel
  78791. * @param name of SelectionPanel
  78792. * @param groups is an array of SelectionGroups
  78793. */
  78794. constructor(
  78795. /** name of SelectionPanel */
  78796. name: string,
  78797. /** an array of SelectionGroups */
  78798. groups?: SelectorGroup[]);
  78799. protected _getTypeName(): string;
  78800. /** Gets or sets the headerColor */
  78801. get headerColor(): string;
  78802. set headerColor(color: string);
  78803. private _setHeaderColor;
  78804. /** Gets or sets the button color */
  78805. get buttonColor(): string;
  78806. set buttonColor(color: string);
  78807. private _setbuttonColor;
  78808. /** Gets or sets the label color */
  78809. get labelColor(): string;
  78810. set labelColor(color: string);
  78811. private _setLabelColor;
  78812. /** Gets or sets the button background */
  78813. get buttonBackground(): string;
  78814. set buttonBackground(color: string);
  78815. private _setButtonBackground;
  78816. /** Gets or sets the color of separator bar */
  78817. get barColor(): string;
  78818. set barColor(color: string);
  78819. private _setBarColor;
  78820. /** Gets or sets the height of separator bar */
  78821. get barHeight(): string;
  78822. set barHeight(value: string);
  78823. private _setBarHeight;
  78824. /** Gets or sets the height of spacers*/
  78825. get spacerHeight(): string;
  78826. set spacerHeight(value: string);
  78827. private _setSpacerHeight;
  78828. /** Adds a bar between groups */
  78829. private _addSpacer;
  78830. /** Add a group to the selection panel
  78831. * @param group is the selector group to add
  78832. */
  78833. addGroup(group: SelectorGroup): void;
  78834. /** Remove the group from the given position
  78835. * @param groupNb is the position of the group in the list
  78836. */
  78837. removeGroup(groupNb: number): void;
  78838. /** Change a group header label
  78839. * @param label is the new group header label
  78840. * @param groupNb is the number of the group to relabel
  78841. * */
  78842. setHeaderName(label: string, groupNb: number): void;
  78843. /** Change selector label to the one given
  78844. * @param label is the new selector label
  78845. * @param groupNb is the number of the groupcontaining the selector
  78846. * @param selectorNb is the number of the selector within a group to relabel
  78847. * */
  78848. relabel(label: string, groupNb: number, selectorNb: number): void;
  78849. /** For a given group position remove the selector at the given position
  78850. * @param groupNb is the number of the group to remove the selector from
  78851. * @param selectorNb is the number of the selector within the group
  78852. */
  78853. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78854. /** For a given group position of correct type add a checkbox button
  78855. * @param groupNb is the number of the group to remove the selector from
  78856. * @param label is the label for the selector
  78857. * @param func is the function called when the Selector is checked
  78858. * @param checked is true when Selector is checked
  78859. */
  78860. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78861. /** For a given group position of correct type add a radio button
  78862. * @param groupNb is the number of the group to remove the selector from
  78863. * @param label is the label for the selector
  78864. * @param func is the function called when the Selector is checked
  78865. * @param checked is true when Selector is checked
  78866. */
  78867. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78868. /**
  78869. * For a given slider group add a slider
  78870. * @param groupNb is the number of the group to add the slider to
  78871. * @param label is the label for the Slider
  78872. * @param func is the function called when the Slider moves
  78873. * @param unit is a string describing the units used, eg degrees or metres
  78874. * @param min is the minimum value for the Slider
  78875. * @param max is the maximum value for the Slider
  78876. * @param value is the start value for the Slider between min and max
  78877. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78878. */
  78879. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78880. }
  78881. }
  78882. declare module BABYLON.GUI {
  78883. /**
  78884. * Class used to hold a the container for ScrollViewer
  78885. * @hidden
  78886. */
  78887. export class _ScrollViewerWindow extends Container {
  78888. parentClientWidth: number;
  78889. parentClientHeight: number;
  78890. private _freezeControls;
  78891. private _parentMeasure;
  78892. private _oldLeft;
  78893. private _oldTop;
  78894. get freezeControls(): boolean;
  78895. set freezeControls(value: boolean);
  78896. private _bucketWidth;
  78897. private _bucketHeight;
  78898. private _buckets;
  78899. private _bucketLen;
  78900. get bucketWidth(): number;
  78901. get bucketHeight(): number;
  78902. setBucketSizes(width: number, height: number): void;
  78903. private _useBuckets;
  78904. private _makeBuckets;
  78905. private _dispatchInBuckets;
  78906. private _updateMeasures;
  78907. private _updateChildrenMeasures;
  78908. private _restoreMeasures;
  78909. /**
  78910. * Creates a new ScrollViewerWindow
  78911. * @param name of ScrollViewerWindow
  78912. */
  78913. constructor(name?: string);
  78914. protected _getTypeName(): string;
  78915. /** @hidden */
  78916. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78917. /** @hidden */
  78918. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78919. private _scrollChildren;
  78920. private _scrollChildrenWithBuckets;
  78921. /** @hidden */
  78922. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78923. protected _postMeasure(): void;
  78924. }
  78925. }
  78926. declare module BABYLON.GUI {
  78927. /**
  78928. * Class used to create slider controls
  78929. */
  78930. export class ScrollBar extends BaseSlider {
  78931. name?: string | undefined;
  78932. private _background;
  78933. private _borderColor;
  78934. private _tempMeasure;
  78935. /** Gets or sets border color */
  78936. get borderColor(): string;
  78937. set borderColor(value: string);
  78938. /** Gets or sets background color */
  78939. get background(): string;
  78940. set background(value: string);
  78941. /**
  78942. * Creates a new Slider
  78943. * @param name defines the control name
  78944. */
  78945. constructor(name?: string | undefined);
  78946. protected _getTypeName(): string;
  78947. protected _getThumbThickness(): number;
  78948. _draw(context: CanvasRenderingContext2D): void;
  78949. private _first;
  78950. private _originX;
  78951. private _originY;
  78952. /** @hidden */
  78953. protected _updateValueFromPointer(x: number, y: number): void;
  78954. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78955. }
  78956. }
  78957. declare module BABYLON.GUI {
  78958. /**
  78959. * Class used to create slider controls
  78960. */
  78961. export class ImageScrollBar extends BaseSlider {
  78962. name?: string | undefined;
  78963. private _backgroundBaseImage;
  78964. private _backgroundImage;
  78965. private _thumbImage;
  78966. private _thumbBaseImage;
  78967. private _thumbLength;
  78968. private _thumbHeight;
  78969. private _barImageHeight;
  78970. private _tempMeasure;
  78971. /** Number of 90° rotation to apply on the images when in vertical mode */
  78972. num90RotationInVerticalMode: number;
  78973. /**
  78974. * Gets or sets the image used to render the background for horizontal bar
  78975. */
  78976. get backgroundImage(): Image;
  78977. set backgroundImage(value: Image);
  78978. /**
  78979. * Gets or sets the image used to render the thumb
  78980. */
  78981. get thumbImage(): Image;
  78982. set thumbImage(value: Image);
  78983. /**
  78984. * Gets or sets the length of the thumb
  78985. */
  78986. get thumbLength(): number;
  78987. set thumbLength(value: number);
  78988. /**
  78989. * Gets or sets the height of the thumb
  78990. */
  78991. get thumbHeight(): number;
  78992. set thumbHeight(value: number);
  78993. /**
  78994. * Gets or sets the height of the bar image
  78995. */
  78996. get barImageHeight(): number;
  78997. set barImageHeight(value: number);
  78998. /**
  78999. * Creates a new ImageScrollBar
  79000. * @param name defines the control name
  79001. */
  79002. constructor(name?: string | undefined);
  79003. protected _getTypeName(): string;
  79004. protected _getThumbThickness(): number;
  79005. _draw(context: CanvasRenderingContext2D): void;
  79006. private _first;
  79007. private _originX;
  79008. private _originY;
  79009. /** @hidden */
  79010. protected _updateValueFromPointer(x: number, y: number): void;
  79011. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79012. }
  79013. }
  79014. declare module BABYLON.GUI {
  79015. /**
  79016. * Class used to hold a viewer window and sliders in a grid
  79017. */
  79018. export class ScrollViewer extends Rectangle {
  79019. private _grid;
  79020. private _horizontalBarSpace;
  79021. private _verticalBarSpace;
  79022. private _dragSpace;
  79023. private _horizontalBar;
  79024. private _verticalBar;
  79025. private _barColor;
  79026. private _barBackground;
  79027. private _barImage;
  79028. private _horizontalBarImage;
  79029. private _verticalBarImage;
  79030. private _barBackgroundImage;
  79031. private _horizontalBarBackgroundImage;
  79032. private _verticalBarBackgroundImage;
  79033. private _barSize;
  79034. private _window;
  79035. private _pointerIsOver;
  79036. private _wheelPrecision;
  79037. private _onWheelObserver;
  79038. private _clientWidth;
  79039. private _clientHeight;
  79040. private _useImageBar;
  79041. private _thumbLength;
  79042. private _thumbHeight;
  79043. private _barImageHeight;
  79044. private _horizontalBarImageHeight;
  79045. private _verticalBarImageHeight;
  79046. private _oldWindowContentsWidth;
  79047. private _oldWindowContentsHeight;
  79048. /**
  79049. * Gets the horizontal scrollbar
  79050. */
  79051. get horizontalBar(): ScrollBar | ImageScrollBar;
  79052. /**
  79053. * Gets the vertical scrollbar
  79054. */
  79055. get verticalBar(): ScrollBar | ImageScrollBar;
  79056. /**
  79057. * Adds a new control to the current container
  79058. * @param control defines the control to add
  79059. * @returns the current container
  79060. */
  79061. addControl(control: BABYLON.Nullable<Control>): Container;
  79062. /**
  79063. * Removes a control from the current container
  79064. * @param control defines the control to remove
  79065. * @returns the current container
  79066. */
  79067. removeControl(control: Control): Container;
  79068. /** Gets the list of children */
  79069. get children(): Control[];
  79070. _flagDescendantsAsMatrixDirty(): void;
  79071. /**
  79072. * Freezes or unfreezes the controls in the window.
  79073. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79074. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79075. */
  79076. get freezeControls(): boolean;
  79077. set freezeControls(value: boolean);
  79078. /** Gets the bucket width */
  79079. get bucketWidth(): number;
  79080. /** Gets the bucket height */
  79081. get bucketHeight(): number;
  79082. /**
  79083. * Sets the bucket sizes.
  79084. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79085. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79086. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79087. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79088. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79089. * used), that's why it is not enabled by default.
  79090. * @param width width of the bucket
  79091. * @param height height of the bucket
  79092. */
  79093. setBucketSizes(width: number, height: number): void;
  79094. private _forceHorizontalBar;
  79095. private _forceVerticalBar;
  79096. /**
  79097. * Forces the horizontal scroll bar to be displayed
  79098. */
  79099. get forceHorizontalBar(): boolean;
  79100. set forceHorizontalBar(value: boolean);
  79101. /**
  79102. * Forces the vertical scroll bar to be displayed
  79103. */
  79104. get forceVerticalBar(): boolean;
  79105. set forceVerticalBar(value: boolean);
  79106. /**
  79107. * Creates a new ScrollViewer
  79108. * @param name of ScrollViewer
  79109. */
  79110. constructor(name?: string, isImageBased?: boolean);
  79111. /** Reset the scroll viewer window to initial size */
  79112. resetWindow(): void;
  79113. protected _getTypeName(): string;
  79114. private _buildClientSizes;
  79115. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79116. protected _postMeasure(): void;
  79117. /**
  79118. * Gets or sets the mouse wheel precision
  79119. * from 0 to 1 with a default value of 0.05
  79120. * */
  79121. get wheelPrecision(): number;
  79122. set wheelPrecision(value: number);
  79123. /** Gets or sets the scroll bar container background color */
  79124. get scrollBackground(): string;
  79125. set scrollBackground(color: string);
  79126. /** Gets or sets the bar color */
  79127. get barColor(): string;
  79128. set barColor(color: string);
  79129. /** Gets or sets the bar image */
  79130. get thumbImage(): Image;
  79131. set thumbImage(value: Image);
  79132. /** Gets or sets the horizontal bar image */
  79133. get horizontalThumbImage(): Image;
  79134. set horizontalThumbImage(value: Image);
  79135. /** Gets or sets the vertical bar image */
  79136. get verticalThumbImage(): Image;
  79137. set verticalThumbImage(value: Image);
  79138. /** Gets or sets the size of the bar */
  79139. get barSize(): number;
  79140. set barSize(value: number);
  79141. /** Gets or sets the length of the thumb */
  79142. get thumbLength(): number;
  79143. set thumbLength(value: number);
  79144. /** Gets or sets the height of the thumb */
  79145. get thumbHeight(): number;
  79146. set thumbHeight(value: number);
  79147. /** Gets or sets the height of the bar image */
  79148. get barImageHeight(): number;
  79149. set barImageHeight(value: number);
  79150. /** Gets or sets the height of the horizontal bar image */
  79151. get horizontalBarImageHeight(): number;
  79152. set horizontalBarImageHeight(value: number);
  79153. /** Gets or sets the height of the vertical bar image */
  79154. get verticalBarImageHeight(): number;
  79155. set verticalBarImageHeight(value: number);
  79156. /** Gets or sets the bar background */
  79157. get barBackground(): string;
  79158. set barBackground(color: string);
  79159. /** Gets or sets the bar background image */
  79160. get barImage(): Image;
  79161. set barImage(value: Image);
  79162. /** Gets or sets the horizontal bar background image */
  79163. get horizontalBarImage(): Image;
  79164. set horizontalBarImage(value: Image);
  79165. /** Gets or sets the vertical bar background image */
  79166. get verticalBarImage(): Image;
  79167. set verticalBarImage(value: Image);
  79168. private _setWindowPosition;
  79169. /** @hidden */
  79170. private _updateScroller;
  79171. _link(host: AdvancedDynamicTexture): void;
  79172. /** @hidden */
  79173. private _addBar;
  79174. /** @hidden */
  79175. private _attachWheel;
  79176. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79177. /** Releases associated resources */
  79178. dispose(): void;
  79179. }
  79180. }
  79181. declare module BABYLON.GUI {
  79182. /** Class used to render a grid */
  79183. export class DisplayGrid extends Control {
  79184. name?: string | undefined;
  79185. private _cellWidth;
  79186. private _cellHeight;
  79187. private _minorLineTickness;
  79188. private _minorLineColor;
  79189. private _majorLineTickness;
  79190. private _majorLineColor;
  79191. private _majorLineFrequency;
  79192. private _background;
  79193. private _displayMajorLines;
  79194. private _displayMinorLines;
  79195. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79196. get displayMinorLines(): boolean;
  79197. set displayMinorLines(value: boolean);
  79198. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79199. get displayMajorLines(): boolean;
  79200. set displayMajorLines(value: boolean);
  79201. /** Gets or sets background color (Black by default) */
  79202. get background(): string;
  79203. set background(value: string);
  79204. /** Gets or sets the width of each cell (20 by default) */
  79205. get cellWidth(): number;
  79206. set cellWidth(value: number);
  79207. /** Gets or sets the height of each cell (20 by default) */
  79208. get cellHeight(): number;
  79209. set cellHeight(value: number);
  79210. /** Gets or sets the tickness of minor lines (1 by default) */
  79211. get minorLineTickness(): number;
  79212. set minorLineTickness(value: number);
  79213. /** Gets or sets the color of minor lines (DarkGray by default) */
  79214. get minorLineColor(): string;
  79215. set minorLineColor(value: string);
  79216. /** Gets or sets the tickness of major lines (2 by default) */
  79217. get majorLineTickness(): number;
  79218. set majorLineTickness(value: number);
  79219. /** Gets or sets the color of major lines (White by default) */
  79220. get majorLineColor(): string;
  79221. set majorLineColor(value: string);
  79222. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79223. get majorLineFrequency(): number;
  79224. set majorLineFrequency(value: number);
  79225. /**
  79226. * Creates a new GridDisplayRectangle
  79227. * @param name defines the control name
  79228. */
  79229. constructor(name?: string | undefined);
  79230. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79231. protected _getTypeName(): string;
  79232. }
  79233. }
  79234. declare module BABYLON.GUI {
  79235. /**
  79236. * Class used to create slider controls based on images
  79237. */
  79238. export class ImageBasedSlider extends BaseSlider {
  79239. name?: string | undefined;
  79240. private _backgroundImage;
  79241. private _thumbImage;
  79242. private _valueBarImage;
  79243. private _tempMeasure;
  79244. get displayThumb(): boolean;
  79245. set displayThumb(value: boolean);
  79246. /**
  79247. * Gets or sets the image used to render the background
  79248. */
  79249. get backgroundImage(): Image;
  79250. set backgroundImage(value: Image);
  79251. /**
  79252. * Gets or sets the image used to render the value bar
  79253. */
  79254. get valueBarImage(): Image;
  79255. set valueBarImage(value: Image);
  79256. /**
  79257. * Gets or sets the image used to render the thumb
  79258. */
  79259. get thumbImage(): Image;
  79260. set thumbImage(value: Image);
  79261. /**
  79262. * Creates a new ImageBasedSlider
  79263. * @param name defines the control name
  79264. */
  79265. constructor(name?: string | undefined);
  79266. protected _getTypeName(): string;
  79267. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79268. }
  79269. }
  79270. declare module BABYLON.GUI {
  79271. /**
  79272. * Forcing an export so that this code will execute
  79273. * @hidden
  79274. */
  79275. const name = "Statics";
  79276. }
  79277. declare module BABYLON.GUI {
  79278. /**
  79279. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79280. */
  79281. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79282. /**
  79283. * Define the instrumented AdvancedDynamicTexture.
  79284. */
  79285. texture: AdvancedDynamicTexture;
  79286. private _captureRenderTime;
  79287. private _renderTime;
  79288. private _captureLayoutTime;
  79289. private _layoutTime;
  79290. private _onBeginRenderObserver;
  79291. private _onEndRenderObserver;
  79292. private _onBeginLayoutObserver;
  79293. private _onEndLayoutObserver;
  79294. /**
  79295. * Gets the perf counter used to capture render time
  79296. */
  79297. get renderTimeCounter(): BABYLON.PerfCounter;
  79298. /**
  79299. * Gets the perf counter used to capture layout time
  79300. */
  79301. get layoutTimeCounter(): BABYLON.PerfCounter;
  79302. /**
  79303. * Enable or disable the render time capture
  79304. */
  79305. get captureRenderTime(): boolean;
  79306. set captureRenderTime(value: boolean);
  79307. /**
  79308. * Enable or disable the layout time capture
  79309. */
  79310. get captureLayoutTime(): boolean;
  79311. set captureLayoutTime(value: boolean);
  79312. /**
  79313. * Instantiates a new advanced dynamic texture instrumentation.
  79314. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79315. * @param texture Defines the AdvancedDynamicTexture to instrument
  79316. */
  79317. constructor(
  79318. /**
  79319. * Define the instrumented AdvancedDynamicTexture.
  79320. */
  79321. texture: AdvancedDynamicTexture);
  79322. /**
  79323. * Dispose and release associated resources.
  79324. */
  79325. dispose(): void;
  79326. }
  79327. }
  79328. declare module BABYLON.GUI {
  79329. /**
  79330. * Class used to load GUI via XML.
  79331. */
  79332. export class XmlLoader {
  79333. private _nodes;
  79334. private _nodeTypes;
  79335. private _isLoaded;
  79336. private _objectAttributes;
  79337. private _parentClass;
  79338. /**
  79339. * Create a new xml loader
  79340. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79341. */
  79342. constructor(parentClass?: null);
  79343. private _getChainElement;
  79344. private _getClassAttribute;
  79345. private _createGuiElement;
  79346. private _parseGrid;
  79347. private _parseElement;
  79348. private _prepareSourceElement;
  79349. private _parseElementsFromSource;
  79350. private _parseXml;
  79351. /**
  79352. * Gets if the loading has finished.
  79353. * @returns whether the loading has finished or not
  79354. */
  79355. isLoaded(): boolean;
  79356. /**
  79357. * Gets a loaded node / control by id.
  79358. * @param id the Controls id set in the xml
  79359. * @returns element of type Control
  79360. */
  79361. getNodeById(id: string): any;
  79362. /**
  79363. * Gets all loaded nodes / controls
  79364. * @returns Array of controls
  79365. */
  79366. getNodes(): any;
  79367. /**
  79368. * Initiates the xml layout loading
  79369. * @param xmlFile defines the xml layout to load
  79370. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79371. * @param callback defines the callback called on layout load.
  79372. */
  79373. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79374. }
  79375. }
  79376. declare module BABYLON.GUI {
  79377. /**
  79378. * Class used to create containers for controls
  79379. */
  79380. export class Container3D extends Control3D {
  79381. private _blockLayout;
  79382. /**
  79383. * Gets the list of child controls
  79384. */
  79385. protected _children: Control3D[];
  79386. /**
  79387. * Gets the list of child controls
  79388. */
  79389. get children(): Array<Control3D>;
  79390. /**
  79391. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79392. * This is helpful to optimize layout operation when adding multiple children in a row
  79393. */
  79394. get blockLayout(): boolean;
  79395. set blockLayout(value: boolean);
  79396. /**
  79397. * Creates a new container
  79398. * @param name defines the container name
  79399. */
  79400. constructor(name?: string);
  79401. /**
  79402. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79403. * @returns the current container
  79404. */
  79405. updateLayout(): Container3D;
  79406. /**
  79407. * Gets a boolean indicating if the given control is in the children of this control
  79408. * @param control defines the control to check
  79409. * @returns true if the control is in the child list
  79410. */
  79411. containsControl(control: Control3D): boolean;
  79412. /**
  79413. * Adds a control to the children of this control
  79414. * @param control defines the control to add
  79415. * @returns the current container
  79416. */
  79417. addControl(control: Control3D): Container3D;
  79418. /**
  79419. * This function will be called everytime a new control is added
  79420. */
  79421. protected _arrangeChildren(): void;
  79422. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79423. /**
  79424. * Removes a control from the children of this control
  79425. * @param control defines the control to remove
  79426. * @returns the current container
  79427. */
  79428. removeControl(control: Control3D): Container3D;
  79429. protected _getTypeName(): string;
  79430. /**
  79431. * Releases all associated resources
  79432. */
  79433. dispose(): void;
  79434. /** Control rotation will remain unchanged */
  79435. static readonly UNSET_ORIENTATION: number;
  79436. /** Control will rotate to make it look at sphere central axis */
  79437. static readonly FACEORIGIN_ORIENTATION: number;
  79438. /** Control will rotate to make it look back at sphere central axis */
  79439. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79440. /** Control will rotate to look at z axis (0, 0, 1) */
  79441. static readonly FACEFORWARD_ORIENTATION: number;
  79442. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79443. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79444. }
  79445. }
  79446. declare module BABYLON.GUI {
  79447. /**
  79448. * Class used to manage 3D user interface
  79449. * @see https://doc.babylonjs.com/how_to/gui3d
  79450. */
  79451. export class GUI3DManager implements BABYLON.IDisposable {
  79452. private _scene;
  79453. private _sceneDisposeObserver;
  79454. private _utilityLayer;
  79455. private _rootContainer;
  79456. private _pointerObserver;
  79457. private _pointerOutObserver;
  79458. /** @hidden */
  79459. _lastPickedControl: Control3D;
  79460. /** @hidden */
  79461. _lastControlOver: {
  79462. [pointerId: number]: Control3D;
  79463. };
  79464. /** @hidden */
  79465. _lastControlDown: {
  79466. [pointerId: number]: Control3D;
  79467. };
  79468. /**
  79469. * BABYLON.Observable raised when the point picked by the pointer events changed
  79470. */
  79471. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79472. /** @hidden */
  79473. _sharedMaterials: {
  79474. [key: string]: BABYLON.Material;
  79475. };
  79476. /** Gets the hosting scene */
  79477. get scene(): BABYLON.Scene;
  79478. /** Gets associated utility layer */
  79479. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79480. /**
  79481. * Creates a new GUI3DManager
  79482. * @param scene
  79483. */
  79484. constructor(scene?: BABYLON.Scene);
  79485. private _handlePointerOut;
  79486. private _doPicking;
  79487. /**
  79488. * Gets the root container
  79489. */
  79490. get rootContainer(): Container3D;
  79491. /**
  79492. * Gets a boolean indicating if the given control is in the root child list
  79493. * @param control defines the control to check
  79494. * @returns true if the control is in the root child list
  79495. */
  79496. containsControl(control: Control3D): boolean;
  79497. /**
  79498. * Adds a control to the root child list
  79499. * @param control defines the control to add
  79500. * @returns the current manager
  79501. */
  79502. addControl(control: Control3D): GUI3DManager;
  79503. /**
  79504. * Removes a control from the root child list
  79505. * @param control defines the control to remove
  79506. * @returns the current container
  79507. */
  79508. removeControl(control: Control3D): GUI3DManager;
  79509. /**
  79510. * Releases all associated resources
  79511. */
  79512. dispose(): void;
  79513. }
  79514. }
  79515. declare module BABYLON.GUI {
  79516. /**
  79517. * Class used to transport BABYLON.Vector3 information for pointer events
  79518. */
  79519. export class Vector3WithInfo extends BABYLON.Vector3 {
  79520. /** defines the current mouse button index */
  79521. buttonIndex: number;
  79522. /**
  79523. * Creates a new Vector3WithInfo
  79524. * @param source defines the vector3 data to transport
  79525. * @param buttonIndex defines the current mouse button index
  79526. */
  79527. constructor(source: BABYLON.Vector3,
  79528. /** defines the current mouse button index */
  79529. buttonIndex?: number);
  79530. }
  79531. }
  79532. declare module BABYLON.GUI {
  79533. /**
  79534. * Class used as base class for controls
  79535. */
  79536. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79537. /** Defines the control name */
  79538. name?: string | undefined;
  79539. /** @hidden */
  79540. _host: GUI3DManager;
  79541. private _node;
  79542. private _downCount;
  79543. private _enterCount;
  79544. private _downPointerIds;
  79545. private _isVisible;
  79546. /** Gets or sets the control position in world space */
  79547. get position(): BABYLON.Vector3;
  79548. set position(value: BABYLON.Vector3);
  79549. /** Gets or sets the control scaling in world space */
  79550. get scaling(): BABYLON.Vector3;
  79551. set scaling(value: BABYLON.Vector3);
  79552. /** Callback used to start pointer enter animation */
  79553. pointerEnterAnimation: () => void;
  79554. /** Callback used to start pointer out animation */
  79555. pointerOutAnimation: () => void;
  79556. /** Callback used to start pointer down animation */
  79557. pointerDownAnimation: () => void;
  79558. /** Callback used to start pointer up animation */
  79559. pointerUpAnimation: () => void;
  79560. /**
  79561. * An event triggered when the pointer move over the control
  79562. */
  79563. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79564. /**
  79565. * An event triggered when the pointer move out of the control
  79566. */
  79567. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79568. /**
  79569. * An event triggered when the pointer taps the control
  79570. */
  79571. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79572. /**
  79573. * An event triggered when pointer is up
  79574. */
  79575. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79576. /**
  79577. * An event triggered when a control is clicked on (with a mouse)
  79578. */
  79579. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79580. /**
  79581. * An event triggered when pointer enters the control
  79582. */
  79583. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79584. /**
  79585. * Gets or sets the parent container
  79586. */
  79587. parent: BABYLON.Nullable<Container3D>;
  79588. private _behaviors;
  79589. /**
  79590. * Gets the list of attached behaviors
  79591. * @see https://doc.babylonjs.com/features/behaviour
  79592. */
  79593. get behaviors(): BABYLON.Behavior<Control3D>[];
  79594. /**
  79595. * Attach a behavior to the control
  79596. * @see https://doc.babylonjs.com/features/behaviour
  79597. * @param behavior defines the behavior to attach
  79598. * @returns the current control
  79599. */
  79600. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79601. /**
  79602. * Remove an attached behavior
  79603. * @see https://doc.babylonjs.com/features/behaviour
  79604. * @param behavior defines the behavior to attach
  79605. * @returns the current control
  79606. */
  79607. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79608. /**
  79609. * Gets an attached behavior by name
  79610. * @param name defines the name of the behavior to look for
  79611. * @see https://doc.babylonjs.com/features/behaviour
  79612. * @returns null if behavior was not found else the requested behavior
  79613. */
  79614. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79615. /** Gets or sets a boolean indicating if the control is visible */
  79616. get isVisible(): boolean;
  79617. set isVisible(value: boolean);
  79618. /**
  79619. * Creates a new control
  79620. * @param name defines the control name
  79621. */
  79622. constructor(
  79623. /** Defines the control name */
  79624. name?: string | undefined);
  79625. /**
  79626. * Gets a string representing the class name
  79627. */
  79628. get typeName(): string;
  79629. /**
  79630. * Get the current class name of the control.
  79631. * @returns current class name
  79632. */
  79633. getClassName(): string;
  79634. protected _getTypeName(): string;
  79635. /**
  79636. * Gets the transform node used by this control
  79637. */
  79638. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79639. /**
  79640. * Gets the mesh used to render this control
  79641. */
  79642. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79643. /**
  79644. * Link the control as child of the given node
  79645. * @param node defines the node to link to. Use null to unlink the control
  79646. * @returns the current control
  79647. */
  79648. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79649. /** @hidden **/
  79650. _prepareNode(scene: BABYLON.Scene): void;
  79651. /**
  79652. * Node creation.
  79653. * Can be overriden by children
  79654. * @param scene defines the scene where the node must be attached
  79655. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79656. */
  79657. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79658. /**
  79659. * Affect a material to the given mesh
  79660. * @param mesh defines the mesh which will represent the control
  79661. */
  79662. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79663. /** @hidden */
  79664. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79665. /** @hidden */
  79666. _onPointerEnter(target: Control3D): boolean;
  79667. /** @hidden */
  79668. _onPointerOut(target: Control3D): void;
  79669. /** @hidden */
  79670. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79671. /** @hidden */
  79672. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79673. /** @hidden */
  79674. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79675. /** @hidden */
  79676. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79677. /** @hidden */
  79678. _disposeNode(): void;
  79679. /**
  79680. * Releases all associated resources
  79681. */
  79682. dispose(): void;
  79683. }
  79684. }
  79685. declare module BABYLON.GUI {
  79686. /**
  79687. * Class used as a root to all buttons
  79688. */
  79689. export class AbstractButton3D extends Control3D {
  79690. /**
  79691. * Creates a new button
  79692. * @param name defines the control name
  79693. */
  79694. constructor(name?: string);
  79695. protected _getTypeName(): string;
  79696. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79697. }
  79698. }
  79699. declare module BABYLON.GUI {
  79700. /**
  79701. * Class used to create a button in 3D
  79702. */
  79703. export class Button3D extends AbstractButton3D {
  79704. /** @hidden */
  79705. protected _currentMaterial: BABYLON.Material;
  79706. private _facadeTexture;
  79707. private _content;
  79708. private _contentResolution;
  79709. private _contentScaleRatio;
  79710. /**
  79711. * Gets or sets the texture resolution used to render content (512 by default)
  79712. */
  79713. get contentResolution(): BABYLON.int;
  79714. set contentResolution(value: BABYLON.int);
  79715. /**
  79716. * Gets or sets the texture scale ratio used to render content (2 by default)
  79717. */
  79718. get contentScaleRatio(): number;
  79719. set contentScaleRatio(value: number);
  79720. protected _disposeFacadeTexture(): void;
  79721. protected _resetContent(): void;
  79722. /**
  79723. * Creates a new button
  79724. * @param name defines the control name
  79725. */
  79726. constructor(name?: string);
  79727. /**
  79728. * Gets or sets the GUI 2D content used to display the button's facade
  79729. */
  79730. get content(): Control;
  79731. set content(value: Control);
  79732. /**
  79733. * Apply the facade texture (created from the content property).
  79734. * This function can be overloaded by child classes
  79735. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79736. */
  79737. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79738. protected _getTypeName(): string;
  79739. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79740. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79741. /**
  79742. * Releases all associated resources
  79743. */
  79744. dispose(): void;
  79745. }
  79746. }
  79747. declare module BABYLON.GUI {
  79748. /**
  79749. * Abstract class used to create a container panel deployed on the surface of a volume
  79750. */
  79751. export abstract class VolumeBasedPanel extends Container3D {
  79752. private _columns;
  79753. private _rows;
  79754. private _rowThenColum;
  79755. private _orientation;
  79756. protected _cellWidth: number;
  79757. protected _cellHeight: number;
  79758. /**
  79759. * Gets or sets the distance between elements
  79760. */
  79761. margin: number;
  79762. /**
  79763. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79764. * | Value | Type | Description |
  79765. * | ----- | ----------------------------------- | ----------- |
  79766. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79767. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79768. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79769. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79770. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79771. */
  79772. get orientation(): number;
  79773. set orientation(value: number);
  79774. /**
  79775. * Gets or sets the number of columns requested (10 by default).
  79776. * The panel will automatically compute the number of rows based on number of child controls.
  79777. */
  79778. get columns(): BABYLON.int;
  79779. set columns(value: BABYLON.int);
  79780. /**
  79781. * Gets or sets a the number of rows requested.
  79782. * The panel will automatically compute the number of columns based on number of child controls.
  79783. */
  79784. get rows(): BABYLON.int;
  79785. set rows(value: BABYLON.int);
  79786. /**
  79787. * Creates new VolumeBasedPanel
  79788. */
  79789. constructor();
  79790. protected _arrangeChildren(): void;
  79791. /** Child classes must implement this function to provide correct control positioning */
  79792. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79793. /** Child classes can implement this function to provide additional processing */
  79794. protected _finalProcessing(): void;
  79795. }
  79796. }
  79797. declare module BABYLON.GUI {
  79798. /**
  79799. * Class used to create a container panel deployed on the surface of a cylinder
  79800. */
  79801. export class CylinderPanel extends VolumeBasedPanel {
  79802. private _radius;
  79803. /**
  79804. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79805. */
  79806. get radius(): BABYLON.float;
  79807. set radius(value: BABYLON.float);
  79808. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79809. private _cylindricalMapping;
  79810. }
  79811. }
  79812. declare module BABYLON.GUI {
  79813. /** @hidden */
  79814. export var fluentVertexShader: {
  79815. name: string;
  79816. shader: string;
  79817. };
  79818. }
  79819. declare module BABYLON.GUI {
  79820. /** @hidden */
  79821. export var fluentPixelShader: {
  79822. name: string;
  79823. shader: string;
  79824. };
  79825. }
  79826. declare module BABYLON.GUI {
  79827. /** @hidden */
  79828. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79829. INNERGLOW: boolean;
  79830. BORDER: boolean;
  79831. HOVERLIGHT: boolean;
  79832. TEXTURE: boolean;
  79833. constructor();
  79834. }
  79835. /**
  79836. * Class used to render controls with fluent desgin
  79837. */
  79838. export class FluentMaterial extends BABYLON.PushMaterial {
  79839. /**
  79840. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79841. */
  79842. innerGlowColorIntensity: number;
  79843. /**
  79844. * Gets or sets the inner glow color (white by default)
  79845. */
  79846. innerGlowColor: BABYLON.Color3;
  79847. /**
  79848. * Gets or sets alpha value (default is 1.0)
  79849. */
  79850. alpha: number;
  79851. /**
  79852. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79853. */
  79854. albedoColor: BABYLON.Color3;
  79855. /**
  79856. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79857. */
  79858. renderBorders: boolean;
  79859. /**
  79860. * Gets or sets border width (default is 0.5)
  79861. */
  79862. borderWidth: number;
  79863. /**
  79864. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79865. */
  79866. edgeSmoothingValue: number;
  79867. /**
  79868. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79869. */
  79870. borderMinValue: number;
  79871. /**
  79872. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79873. */
  79874. renderHoverLight: boolean;
  79875. /**
  79876. * Gets or sets the radius used to render the hover light (default is 1.0)
  79877. */
  79878. hoverRadius: number;
  79879. /**
  79880. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79881. */
  79882. hoverColor: BABYLON.Color4;
  79883. /**
  79884. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79885. */
  79886. hoverPosition: BABYLON.Vector3;
  79887. private _albedoTexture;
  79888. /** Gets or sets the texture to use for albedo color */
  79889. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79890. /**
  79891. * Creates a new Fluent material
  79892. * @param name defines the name of the material
  79893. * @param scene defines the hosting scene
  79894. */
  79895. constructor(name: string, scene: BABYLON.Scene);
  79896. needAlphaBlending(): boolean;
  79897. needAlphaTesting(): boolean;
  79898. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79899. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79900. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79901. getActiveTextures(): BABYLON.BaseTexture[];
  79902. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79903. dispose(forceDisposeEffect?: boolean): void;
  79904. clone(name: string): FluentMaterial;
  79905. serialize(): any;
  79906. getClassName(): string;
  79907. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79908. }
  79909. }
  79910. declare module BABYLON.GUI {
  79911. /**
  79912. * Class used to create a holographic button in 3D
  79913. */
  79914. export class HolographicButton extends Button3D {
  79915. private _backPlate;
  79916. private _textPlate;
  79917. private _frontPlate;
  79918. private _text;
  79919. private _imageUrl;
  79920. private _shareMaterials;
  79921. private _frontMaterial;
  79922. private _backMaterial;
  79923. private _plateMaterial;
  79924. private _pickedPointObserver;
  79925. private _tooltipFade;
  79926. private _tooltipTextBlock;
  79927. private _tooltipTexture;
  79928. private _tooltipMesh;
  79929. private _tooltipHoverObserver;
  79930. private _tooltipOutObserver;
  79931. private _disposeTooltip;
  79932. /**
  79933. * Rendering ground id of all the mesh in the button
  79934. */
  79935. set renderingGroupId(id: number);
  79936. get renderingGroupId(): number;
  79937. /**
  79938. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79939. */
  79940. set tooltipText(text: BABYLON.Nullable<string>);
  79941. get tooltipText(): BABYLON.Nullable<string>;
  79942. /**
  79943. * Gets or sets text for the button
  79944. */
  79945. get text(): string;
  79946. set text(value: string);
  79947. /**
  79948. * Gets or sets the image url for the button
  79949. */
  79950. get imageUrl(): string;
  79951. set imageUrl(value: string);
  79952. /**
  79953. * Gets the back material used by this button
  79954. */
  79955. get backMaterial(): FluentMaterial;
  79956. /**
  79957. * Gets the front material used by this button
  79958. */
  79959. get frontMaterial(): FluentMaterial;
  79960. /**
  79961. * Gets the plate material used by this button
  79962. */
  79963. get plateMaterial(): BABYLON.StandardMaterial;
  79964. /**
  79965. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79966. */
  79967. get shareMaterials(): boolean;
  79968. /**
  79969. * Creates a new button
  79970. * @param name defines the control name
  79971. */
  79972. constructor(name?: string, shareMaterials?: boolean);
  79973. protected _getTypeName(): string;
  79974. private _rebuildContent;
  79975. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79976. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79977. private _createBackMaterial;
  79978. private _createFrontMaterial;
  79979. private _createPlateMaterial;
  79980. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79981. /**
  79982. * Releases all associated resources
  79983. */
  79984. dispose(): void;
  79985. }
  79986. }
  79987. declare module BABYLON.GUI {
  79988. /**
  79989. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79990. */
  79991. export class MeshButton3D extends Button3D {
  79992. /** @hidden */
  79993. protected _currentMesh: BABYLON.Mesh;
  79994. /**
  79995. * Creates a new 3D button based on a mesh
  79996. * @param mesh mesh to become a 3D button
  79997. * @param name defines the control name
  79998. */
  79999. constructor(mesh: BABYLON.Mesh, name?: string);
  80000. protected _getTypeName(): string;
  80001. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80002. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80003. }
  80004. }
  80005. declare module BABYLON.GUI {
  80006. /**
  80007. * Class used to create a container panel deployed on the surface of a plane
  80008. */
  80009. export class PlanePanel extends VolumeBasedPanel {
  80010. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80011. }
  80012. }
  80013. declare module BABYLON.GUI {
  80014. /**
  80015. * Class used to create a container panel where items get randomized planar mapping
  80016. */
  80017. export class ScatterPanel extends VolumeBasedPanel {
  80018. private _iteration;
  80019. /**
  80020. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80021. */
  80022. get iteration(): BABYLON.float;
  80023. set iteration(value: BABYLON.float);
  80024. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80025. private _scatterMapping;
  80026. protected _finalProcessing(): void;
  80027. }
  80028. }
  80029. declare module BABYLON.GUI {
  80030. /**
  80031. * Class used to create a container panel deployed on the surface of a sphere
  80032. */
  80033. export class SpherePanel extends VolumeBasedPanel {
  80034. private _radius;
  80035. /**
  80036. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80037. */
  80038. get radius(): BABYLON.float;
  80039. set radius(value: BABYLON.float);
  80040. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80041. private _sphericalMapping;
  80042. }
  80043. }
  80044. declare module BABYLON.GUI {
  80045. /**
  80046. * Class used to create a stack panel in 3D on XY plane
  80047. */
  80048. export class StackPanel3D extends Container3D {
  80049. private _isVertical;
  80050. /**
  80051. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80052. */
  80053. get isVertical(): boolean;
  80054. set isVertical(value: boolean);
  80055. /**
  80056. * Gets or sets the distance between elements
  80057. */
  80058. margin: number;
  80059. /**
  80060. * Creates new StackPanel
  80061. * @param isVertical
  80062. */
  80063. constructor(isVertical?: boolean);
  80064. protected _arrangeChildren(): void;
  80065. }
  80066. }
  80067. declare module BABYLON {
  80068. /**
  80069. * Configuration for glTF validation
  80070. */
  80071. export interface IGLTFValidationConfiguration {
  80072. /**
  80073. * The url of the glTF validator.
  80074. */
  80075. url: string;
  80076. }
  80077. /**
  80078. * glTF validation
  80079. */
  80080. export class GLTFValidation {
  80081. /**
  80082. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80083. */
  80084. static Configuration: IGLTFValidationConfiguration;
  80085. private static _LoadScriptPromise;
  80086. /**
  80087. * Validate a glTF asset using the glTF-Validator.
  80088. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80089. * @param rootUrl The root url for the glTF
  80090. * @param fileName The file name for the glTF
  80091. * @param getExternalResource The callback to get external resources for the glTF validator
  80092. * @returns A promise that resolves with the glTF validation results once complete
  80093. */
  80094. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80095. }
  80096. }
  80097. declare module BABYLON {
  80098. /**
  80099. * Mode that determines the coordinate system to use.
  80100. */
  80101. export enum GLTFLoaderCoordinateSystemMode {
  80102. /**
  80103. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80104. */
  80105. AUTO = 0,
  80106. /**
  80107. * Sets the useRightHandedSystem flag on the scene.
  80108. */
  80109. FORCE_RIGHT_HANDED = 1
  80110. }
  80111. /**
  80112. * Mode that determines what animations will start.
  80113. */
  80114. export enum GLTFLoaderAnimationStartMode {
  80115. /**
  80116. * No animation will start.
  80117. */
  80118. NONE = 0,
  80119. /**
  80120. * The first animation will start.
  80121. */
  80122. FIRST = 1,
  80123. /**
  80124. * All animations will start.
  80125. */
  80126. ALL = 2
  80127. }
  80128. /**
  80129. * Interface that contains the data for the glTF asset.
  80130. */
  80131. export interface IGLTFLoaderData {
  80132. /**
  80133. * The object that represents the glTF JSON.
  80134. */
  80135. json: Object;
  80136. /**
  80137. * The BIN chunk of a binary glTF.
  80138. */
  80139. bin: Nullable<IDataBuffer>;
  80140. }
  80141. /**
  80142. * Interface for extending the loader.
  80143. */
  80144. export interface IGLTFLoaderExtension {
  80145. /**
  80146. * The name of this extension.
  80147. */
  80148. readonly name: string;
  80149. /**
  80150. * Defines whether this extension is enabled.
  80151. */
  80152. enabled: boolean;
  80153. /**
  80154. * Defines the order of this extension.
  80155. * The loader sorts the extensions using these values when loading.
  80156. */
  80157. order?: number;
  80158. }
  80159. /**
  80160. * Loader state.
  80161. */
  80162. export enum GLTFLoaderState {
  80163. /**
  80164. * The asset is loading.
  80165. */
  80166. LOADING = 0,
  80167. /**
  80168. * The asset is ready for rendering.
  80169. */
  80170. READY = 1,
  80171. /**
  80172. * The asset is completely loaded.
  80173. */
  80174. COMPLETE = 2
  80175. }
  80176. /** @hidden */
  80177. export interface IImportMeshAsyncOutput {
  80178. meshes: AbstractMesh[];
  80179. particleSystems: IParticleSystem[];
  80180. skeletons: Skeleton[];
  80181. animationGroups: AnimationGroup[];
  80182. lights: Light[];
  80183. transformNodes: TransformNode[];
  80184. }
  80185. /** @hidden */
  80186. export interface IGLTFLoader extends IDisposable {
  80187. readonly state: Nullable<GLTFLoaderState>;
  80188. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80189. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80190. }
  80191. /**
  80192. * File loader for loading glTF files into a scene.
  80193. */
  80194. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80195. /** @hidden */
  80196. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80197. /** @hidden */
  80198. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80199. /**
  80200. * Raised when the asset has been parsed
  80201. */
  80202. onParsedObservable: Observable<IGLTFLoaderData>;
  80203. private _onParsedObserver;
  80204. /**
  80205. * Raised when the asset has been parsed
  80206. */
  80207. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80208. /**
  80209. * 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.
  80210. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80211. * Defaults to true.
  80212. * @hidden
  80213. */
  80214. static IncrementalLoading: boolean;
  80215. /**
  80216. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80217. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80218. * @hidden
  80219. */
  80220. static HomogeneousCoordinates: boolean;
  80221. /**
  80222. * The coordinate system mode. Defaults to AUTO.
  80223. */
  80224. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80225. /**
  80226. * The animation start mode. Defaults to FIRST.
  80227. */
  80228. animationStartMode: GLTFLoaderAnimationStartMode;
  80229. /**
  80230. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80231. */
  80232. compileMaterials: boolean;
  80233. /**
  80234. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80235. */
  80236. useClipPlane: boolean;
  80237. /**
  80238. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80239. */
  80240. compileShadowGenerators: boolean;
  80241. /**
  80242. * Defines if the Alpha blended materials are only applied as coverage.
  80243. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80244. * If true, no extra effects are applied to transparent pixels.
  80245. */
  80246. transparencyAsCoverage: boolean;
  80247. /**
  80248. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80249. * Enabling will disable offline support and glTF validator.
  80250. * Defaults to false.
  80251. */
  80252. useRangeRequests: boolean;
  80253. /**
  80254. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80255. */
  80256. createInstances: boolean;
  80257. /**
  80258. * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
  80259. */
  80260. alwaysComputeBoundingBox: boolean;
  80261. /**
  80262. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80263. */
  80264. loadAllMaterials: boolean;
  80265. /**
  80266. * Function called before loading a url referenced by the asset.
  80267. */
  80268. preprocessUrlAsync: (url: string) => Promise<string>;
  80269. /**
  80270. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80271. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  80272. */
  80273. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80274. private _onMeshLoadedObserver;
  80275. /**
  80276. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80277. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  80278. */
  80279. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80280. /**
  80281. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80282. */
  80283. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80284. private _onTextureLoadedObserver;
  80285. /**
  80286. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80287. */
  80288. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80289. /**
  80290. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80291. */
  80292. readonly onMaterialLoadedObservable: Observable<Material>;
  80293. private _onMaterialLoadedObserver;
  80294. /**
  80295. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80296. */
  80297. set onMaterialLoaded(callback: (material: Material) => void);
  80298. /**
  80299. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80300. */
  80301. readonly onCameraLoadedObservable: Observable<Camera>;
  80302. private _onCameraLoadedObserver;
  80303. /**
  80304. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80305. */
  80306. set onCameraLoaded(callback: (camera: Camera) => void);
  80307. /**
  80308. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80309. * For assets with LODs, raised when all of the LODs are complete.
  80310. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80311. */
  80312. readonly onCompleteObservable: Observable<void>;
  80313. private _onCompleteObserver;
  80314. /**
  80315. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80316. * For assets with LODs, raised when all of the LODs are complete.
  80317. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80318. */
  80319. set onComplete(callback: () => void);
  80320. /**
  80321. * Observable raised when an error occurs.
  80322. */
  80323. readonly onErrorObservable: Observable<any>;
  80324. private _onErrorObserver;
  80325. /**
  80326. * Callback raised when an error occurs.
  80327. */
  80328. set onError(callback: (reason: any) => void);
  80329. /**
  80330. * Observable raised after the loader is disposed.
  80331. */
  80332. readonly onDisposeObservable: Observable<void>;
  80333. private _onDisposeObserver;
  80334. /**
  80335. * Callback raised after the loader is disposed.
  80336. */
  80337. set onDispose(callback: () => void);
  80338. /**
  80339. * Observable raised after a loader extension is created.
  80340. * Set additional options for a loader extension in this event.
  80341. */
  80342. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80343. private _onExtensionLoadedObserver;
  80344. /**
  80345. * Callback raised after a loader extension is created.
  80346. */
  80347. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80348. /**
  80349. * Defines if the loader logging is enabled.
  80350. */
  80351. get loggingEnabled(): boolean;
  80352. set loggingEnabled(value: boolean);
  80353. /**
  80354. * Defines if the loader should capture performance counters.
  80355. */
  80356. get capturePerformanceCounters(): boolean;
  80357. set capturePerformanceCounters(value: boolean);
  80358. /**
  80359. * Defines if the loader should validate the asset.
  80360. */
  80361. validate: boolean;
  80362. /**
  80363. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80364. */
  80365. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80366. private _onValidatedObserver;
  80367. /**
  80368. * Callback raised after a loader extension is created.
  80369. */
  80370. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80371. private _loader;
  80372. private _progressCallback?;
  80373. private _requests;
  80374. private static magicBase64Encoded;
  80375. /**
  80376. * Name of the loader ("gltf")
  80377. */
  80378. name: string;
  80379. /** @hidden */
  80380. extensions: ISceneLoaderPluginExtensions;
  80381. /**
  80382. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80383. */
  80384. dispose(): void;
  80385. /** @hidden */
  80386. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80387. /** @hidden */
  80388. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80389. /** @hidden */
  80390. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80391. meshes: AbstractMesh[];
  80392. particleSystems: IParticleSystem[];
  80393. skeletons: Skeleton[];
  80394. animationGroups: AnimationGroup[];
  80395. }>;
  80396. /** @hidden */
  80397. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80398. /** @hidden */
  80399. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80400. /** @hidden */
  80401. canDirectLoad(data: string): boolean;
  80402. /** @hidden */
  80403. directLoad(scene: Scene, data: string): Promise<any>;
  80404. /**
  80405. * The callback that allows custom handling of the root url based on the response url.
  80406. * @param rootUrl the original root url
  80407. * @param responseURL the response url if available
  80408. * @returns the new root url
  80409. */
  80410. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80411. /** @hidden */
  80412. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80413. /**
  80414. * The loader state or null if the loader is not active.
  80415. */
  80416. get loaderState(): Nullable<GLTFLoaderState>;
  80417. /**
  80418. * Returns a promise that resolves when the asset is completely loaded.
  80419. * @returns a promise that resolves when the asset is completely loaded.
  80420. */
  80421. whenCompleteAsync(): Promise<void>;
  80422. /** @hidden */
  80423. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80424. /** @hidden */
  80425. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80426. private _onProgress;
  80427. private _validate;
  80428. private _getLoader;
  80429. private _parseJson;
  80430. private _unpackBinaryAsync;
  80431. private _unpackBinaryV1Async;
  80432. private _unpackBinaryV2Async;
  80433. private static _parseVersion;
  80434. private static _compareVersion;
  80435. private static readonly _logSpaces;
  80436. private _logIndentLevel;
  80437. private _loggingEnabled;
  80438. /** @hidden */
  80439. _log: (message: string) => void;
  80440. /** @hidden */
  80441. _logOpen(message: string): void;
  80442. /** @hidden */
  80443. _logClose(): void;
  80444. private _logEnabled;
  80445. private _logDisabled;
  80446. private _capturePerformanceCounters;
  80447. /** @hidden */
  80448. _startPerformanceCounter: (counterName: string) => void;
  80449. /** @hidden */
  80450. _endPerformanceCounter: (counterName: string) => void;
  80451. private _startPerformanceCounterEnabled;
  80452. private _startPerformanceCounterDisabled;
  80453. private _endPerformanceCounterEnabled;
  80454. private _endPerformanceCounterDisabled;
  80455. }
  80456. }
  80457. declare module BABYLON.GLTF1 {
  80458. /**
  80459. * Enums
  80460. * @hidden
  80461. */
  80462. export enum EComponentType {
  80463. BYTE = 5120,
  80464. UNSIGNED_BYTE = 5121,
  80465. SHORT = 5122,
  80466. UNSIGNED_SHORT = 5123,
  80467. FLOAT = 5126
  80468. }
  80469. /** @hidden */
  80470. export enum EShaderType {
  80471. FRAGMENT = 35632,
  80472. VERTEX = 35633
  80473. }
  80474. /** @hidden */
  80475. export enum EParameterType {
  80476. BYTE = 5120,
  80477. UNSIGNED_BYTE = 5121,
  80478. SHORT = 5122,
  80479. UNSIGNED_SHORT = 5123,
  80480. INT = 5124,
  80481. UNSIGNED_INT = 5125,
  80482. FLOAT = 5126,
  80483. FLOAT_VEC2 = 35664,
  80484. FLOAT_VEC3 = 35665,
  80485. FLOAT_VEC4 = 35666,
  80486. INT_VEC2 = 35667,
  80487. INT_VEC3 = 35668,
  80488. INT_VEC4 = 35669,
  80489. BOOL = 35670,
  80490. BOOL_VEC2 = 35671,
  80491. BOOL_VEC3 = 35672,
  80492. BOOL_VEC4 = 35673,
  80493. FLOAT_MAT2 = 35674,
  80494. FLOAT_MAT3 = 35675,
  80495. FLOAT_MAT4 = 35676,
  80496. SAMPLER_2D = 35678
  80497. }
  80498. /** @hidden */
  80499. export enum ETextureWrapMode {
  80500. CLAMP_TO_EDGE = 33071,
  80501. MIRRORED_REPEAT = 33648,
  80502. REPEAT = 10497
  80503. }
  80504. /** @hidden */
  80505. export enum ETextureFilterType {
  80506. NEAREST = 9728,
  80507. LINEAR = 9728,
  80508. NEAREST_MIPMAP_NEAREST = 9984,
  80509. LINEAR_MIPMAP_NEAREST = 9985,
  80510. NEAREST_MIPMAP_LINEAR = 9986,
  80511. LINEAR_MIPMAP_LINEAR = 9987
  80512. }
  80513. /** @hidden */
  80514. export enum ETextureFormat {
  80515. ALPHA = 6406,
  80516. RGB = 6407,
  80517. RGBA = 6408,
  80518. LUMINANCE = 6409,
  80519. LUMINANCE_ALPHA = 6410
  80520. }
  80521. /** @hidden */
  80522. export enum ECullingType {
  80523. FRONT = 1028,
  80524. BACK = 1029,
  80525. FRONT_AND_BACK = 1032
  80526. }
  80527. /** @hidden */
  80528. export enum EBlendingFunction {
  80529. ZERO = 0,
  80530. ONE = 1,
  80531. SRC_COLOR = 768,
  80532. ONE_MINUS_SRC_COLOR = 769,
  80533. DST_COLOR = 774,
  80534. ONE_MINUS_DST_COLOR = 775,
  80535. SRC_ALPHA = 770,
  80536. ONE_MINUS_SRC_ALPHA = 771,
  80537. DST_ALPHA = 772,
  80538. ONE_MINUS_DST_ALPHA = 773,
  80539. CONSTANT_COLOR = 32769,
  80540. ONE_MINUS_CONSTANT_COLOR = 32770,
  80541. CONSTANT_ALPHA = 32771,
  80542. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80543. SRC_ALPHA_SATURATE = 776
  80544. }
  80545. /** @hidden */
  80546. export interface IGLTFProperty {
  80547. extensions?: {
  80548. [key: string]: any;
  80549. };
  80550. extras?: Object;
  80551. }
  80552. /** @hidden */
  80553. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80554. name?: string;
  80555. }
  80556. /** @hidden */
  80557. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80558. bufferView: string;
  80559. byteOffset: number;
  80560. byteStride: number;
  80561. count: number;
  80562. type: string;
  80563. componentType: EComponentType;
  80564. max?: number[];
  80565. min?: number[];
  80566. name?: string;
  80567. }
  80568. /** @hidden */
  80569. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80570. buffer: string;
  80571. byteOffset: number;
  80572. byteLength: number;
  80573. byteStride: number;
  80574. target?: number;
  80575. }
  80576. /** @hidden */
  80577. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80578. uri: string;
  80579. byteLength?: number;
  80580. type?: string;
  80581. }
  80582. /** @hidden */
  80583. export interface IGLTFShader extends IGLTFChildRootProperty {
  80584. uri: string;
  80585. type: EShaderType;
  80586. }
  80587. /** @hidden */
  80588. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80589. attributes: string[];
  80590. fragmentShader: string;
  80591. vertexShader: string;
  80592. }
  80593. /** @hidden */
  80594. export interface IGLTFTechniqueParameter {
  80595. type: number;
  80596. count?: number;
  80597. semantic?: string;
  80598. node?: string;
  80599. value?: number | boolean | string | Array<any>;
  80600. source?: string;
  80601. babylonValue?: any;
  80602. }
  80603. /** @hidden */
  80604. export interface IGLTFTechniqueCommonProfile {
  80605. lightingModel: string;
  80606. texcoordBindings: Object;
  80607. parameters?: Array<any>;
  80608. }
  80609. /** @hidden */
  80610. export interface IGLTFTechniqueStatesFunctions {
  80611. blendColor?: number[];
  80612. blendEquationSeparate?: number[];
  80613. blendFuncSeparate?: number[];
  80614. colorMask: boolean[];
  80615. cullFace: number[];
  80616. }
  80617. /** @hidden */
  80618. export interface IGLTFTechniqueStates {
  80619. enable: number[];
  80620. functions: IGLTFTechniqueStatesFunctions;
  80621. }
  80622. /** @hidden */
  80623. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80624. parameters: {
  80625. [key: string]: IGLTFTechniqueParameter;
  80626. };
  80627. program: string;
  80628. attributes: {
  80629. [key: string]: string;
  80630. };
  80631. uniforms: {
  80632. [key: string]: string;
  80633. };
  80634. states: IGLTFTechniqueStates;
  80635. }
  80636. /** @hidden */
  80637. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80638. technique?: string;
  80639. values: string[];
  80640. }
  80641. /** @hidden */
  80642. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80643. attributes: {
  80644. [key: string]: string;
  80645. };
  80646. indices: string;
  80647. material: string;
  80648. mode?: number;
  80649. }
  80650. /** @hidden */
  80651. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80652. primitives: IGLTFMeshPrimitive[];
  80653. }
  80654. /** @hidden */
  80655. export interface IGLTFImage extends IGLTFChildRootProperty {
  80656. uri: string;
  80657. }
  80658. /** @hidden */
  80659. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80660. magFilter?: number;
  80661. minFilter?: number;
  80662. wrapS?: number;
  80663. wrapT?: number;
  80664. }
  80665. /** @hidden */
  80666. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80667. sampler: string;
  80668. source: string;
  80669. format?: ETextureFormat;
  80670. internalFormat?: ETextureFormat;
  80671. target?: number;
  80672. type?: number;
  80673. babylonTexture?: Texture;
  80674. }
  80675. /** @hidden */
  80676. export interface IGLTFAmbienLight {
  80677. color?: number[];
  80678. }
  80679. /** @hidden */
  80680. export interface IGLTFDirectionalLight {
  80681. color?: number[];
  80682. }
  80683. /** @hidden */
  80684. export interface IGLTFPointLight {
  80685. color?: number[];
  80686. constantAttenuation?: number;
  80687. linearAttenuation?: number;
  80688. quadraticAttenuation?: number;
  80689. }
  80690. /** @hidden */
  80691. export interface IGLTFSpotLight {
  80692. color?: number[];
  80693. constantAttenuation?: number;
  80694. fallOfAngle?: number;
  80695. fallOffExponent?: number;
  80696. linearAttenuation?: number;
  80697. quadraticAttenuation?: number;
  80698. }
  80699. /** @hidden */
  80700. export interface IGLTFLight extends IGLTFChildRootProperty {
  80701. type: string;
  80702. }
  80703. /** @hidden */
  80704. export interface IGLTFCameraOrthographic {
  80705. xmag: number;
  80706. ymag: number;
  80707. zfar: number;
  80708. znear: number;
  80709. }
  80710. /** @hidden */
  80711. export interface IGLTFCameraPerspective {
  80712. aspectRatio: number;
  80713. yfov: number;
  80714. zfar: number;
  80715. znear: number;
  80716. }
  80717. /** @hidden */
  80718. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80719. type: string;
  80720. }
  80721. /** @hidden */
  80722. export interface IGLTFAnimationChannelTarget {
  80723. id: string;
  80724. path: string;
  80725. }
  80726. /** @hidden */
  80727. export interface IGLTFAnimationChannel {
  80728. sampler: string;
  80729. target: IGLTFAnimationChannelTarget;
  80730. }
  80731. /** @hidden */
  80732. export interface IGLTFAnimationSampler {
  80733. input: string;
  80734. output: string;
  80735. interpolation?: string;
  80736. }
  80737. /** @hidden */
  80738. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80739. channels?: IGLTFAnimationChannel[];
  80740. parameters?: {
  80741. [key: string]: string;
  80742. };
  80743. samplers?: {
  80744. [key: string]: IGLTFAnimationSampler;
  80745. };
  80746. }
  80747. /** @hidden */
  80748. export interface IGLTFNodeInstanceSkin {
  80749. skeletons: string[];
  80750. skin: string;
  80751. meshes: string[];
  80752. }
  80753. /** @hidden */
  80754. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80755. bindShapeMatrix: number[];
  80756. inverseBindMatrices: string;
  80757. jointNames: string[];
  80758. babylonSkeleton?: Skeleton;
  80759. }
  80760. /** @hidden */
  80761. export interface IGLTFNode extends IGLTFChildRootProperty {
  80762. camera?: string;
  80763. children: string[];
  80764. skin?: string;
  80765. jointName?: string;
  80766. light?: string;
  80767. matrix: number[];
  80768. mesh?: string;
  80769. meshes?: string[];
  80770. rotation?: number[];
  80771. scale?: number[];
  80772. translation?: number[];
  80773. babylonNode?: Node;
  80774. }
  80775. /** @hidden */
  80776. export interface IGLTFScene extends IGLTFChildRootProperty {
  80777. nodes: string[];
  80778. }
  80779. /** @hidden */
  80780. export interface IGLTFRuntime {
  80781. extensions: {
  80782. [key: string]: any;
  80783. };
  80784. accessors: {
  80785. [key: string]: IGLTFAccessor;
  80786. };
  80787. buffers: {
  80788. [key: string]: IGLTFBuffer;
  80789. };
  80790. bufferViews: {
  80791. [key: string]: IGLTFBufferView;
  80792. };
  80793. meshes: {
  80794. [key: string]: IGLTFMesh;
  80795. };
  80796. lights: {
  80797. [key: string]: IGLTFLight;
  80798. };
  80799. cameras: {
  80800. [key: string]: IGLTFCamera;
  80801. };
  80802. nodes: {
  80803. [key: string]: IGLTFNode;
  80804. };
  80805. images: {
  80806. [key: string]: IGLTFImage;
  80807. };
  80808. textures: {
  80809. [key: string]: IGLTFTexture;
  80810. };
  80811. shaders: {
  80812. [key: string]: IGLTFShader;
  80813. };
  80814. programs: {
  80815. [key: string]: IGLTFProgram;
  80816. };
  80817. samplers: {
  80818. [key: string]: IGLTFSampler;
  80819. };
  80820. techniques: {
  80821. [key: string]: IGLTFTechnique;
  80822. };
  80823. materials: {
  80824. [key: string]: IGLTFMaterial;
  80825. };
  80826. animations: {
  80827. [key: string]: IGLTFAnimation;
  80828. };
  80829. skins: {
  80830. [key: string]: IGLTFSkins;
  80831. };
  80832. currentScene?: Object;
  80833. scenes: {
  80834. [key: string]: IGLTFScene;
  80835. };
  80836. extensionsUsed: string[];
  80837. extensionsRequired?: string[];
  80838. buffersCount: number;
  80839. shaderscount: number;
  80840. scene: Scene;
  80841. rootUrl: string;
  80842. loadedBufferCount: number;
  80843. loadedBufferViews: {
  80844. [name: string]: ArrayBufferView;
  80845. };
  80846. loadedShaderCount: number;
  80847. importOnlyMeshes: boolean;
  80848. importMeshesNames?: string[];
  80849. dummyNodes: Node[];
  80850. forAssetContainer: boolean;
  80851. }
  80852. /** @hidden */
  80853. export interface INodeToRoot {
  80854. bone: Bone;
  80855. node: IGLTFNode;
  80856. id: string;
  80857. }
  80858. /** @hidden */
  80859. export interface IJointNode {
  80860. node: IGLTFNode;
  80861. id: string;
  80862. }
  80863. }
  80864. declare module BABYLON.GLTF1 {
  80865. /**
  80866. * Utils functions for GLTF
  80867. * @hidden
  80868. */
  80869. export class GLTFUtils {
  80870. /**
  80871. * Sets the given "parameter" matrix
  80872. * @param scene: the Scene object
  80873. * @param source: the source node where to pick the matrix
  80874. * @param parameter: the GLTF technique parameter
  80875. * @param uniformName: the name of the shader's uniform
  80876. * @param shaderMaterial: the shader material
  80877. */
  80878. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80879. /**
  80880. * Sets the given "parameter" matrix
  80881. * @param shaderMaterial: the shader material
  80882. * @param uniform: the name of the shader's uniform
  80883. * @param value: the value of the uniform
  80884. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80885. */
  80886. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80887. /**
  80888. * Returns the wrap mode of the texture
  80889. * @param mode: the mode value
  80890. */
  80891. static GetWrapMode(mode: number): number;
  80892. /**
  80893. * Returns the byte stride giving an accessor
  80894. * @param accessor: the GLTF accessor objet
  80895. */
  80896. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80897. /**
  80898. * Returns the texture filter mode giving a mode value
  80899. * @param mode: the filter mode value
  80900. */
  80901. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80902. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80903. /**
  80904. * Returns a buffer from its accessor
  80905. * @param gltfRuntime: the GLTF runtime
  80906. * @param accessor: the GLTF accessor
  80907. */
  80908. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80909. /**
  80910. * Decodes a buffer view into a string
  80911. * @param view: the buffer view
  80912. */
  80913. static DecodeBufferToText(view: ArrayBufferView): string;
  80914. /**
  80915. * Returns the default material of gltf. Related to
  80916. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80917. * @param scene: the Babylon.js scene
  80918. */
  80919. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80920. private static _DefaultMaterial;
  80921. }
  80922. }
  80923. declare module BABYLON.GLTF1 {
  80924. /**
  80925. * Implementation of the base glTF spec
  80926. * @hidden
  80927. */
  80928. export class GLTFLoaderBase {
  80929. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80930. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80931. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80932. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80933. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80934. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80935. }
  80936. /**
  80937. * glTF V1 Loader
  80938. * @hidden
  80939. */
  80940. export class GLTFLoader implements IGLTFLoader {
  80941. static Extensions: {
  80942. [name: string]: GLTFLoaderExtension;
  80943. };
  80944. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80945. state: Nullable<GLTFLoaderState>;
  80946. dispose(): void;
  80947. private _importMeshAsync;
  80948. /**
  80949. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80950. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80951. * @param scene the scene the meshes should be added to
  80952. * @param forAssetContainer defines if the entities must be stored in the scene
  80953. * @param data gltf data containing information of the meshes in a loaded file
  80954. * @param rootUrl root url to load from
  80955. * @param onProgress event that fires when loading progress has occured
  80956. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80957. */
  80958. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80959. private _loadAsync;
  80960. /**
  80961. * Imports all objects from a loaded gltf file and adds them to the scene
  80962. * @param scene the scene the objects should be added to
  80963. * @param data gltf data containing information of the meshes in a loaded file
  80964. * @param rootUrl root url to load from
  80965. * @param onProgress event that fires when loading progress has occured
  80966. * @returns a promise which completes when objects have been loaded to the scene
  80967. */
  80968. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80969. private _loadShadersAsync;
  80970. private _loadBuffersAsync;
  80971. private _createNodes;
  80972. }
  80973. /** @hidden */
  80974. export abstract class GLTFLoaderExtension {
  80975. private _name;
  80976. constructor(name: string);
  80977. get name(): string;
  80978. /**
  80979. * Defines an override for loading the runtime
  80980. * Return true to stop further extensions from loading the runtime
  80981. */
  80982. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80983. /**
  80984. * Defines an onverride for creating gltf runtime
  80985. * Return true to stop further extensions from creating the runtime
  80986. */
  80987. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80988. /**
  80989. * Defines an override for loading buffers
  80990. * Return true to stop further extensions from loading this buffer
  80991. */
  80992. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80993. /**
  80994. * Defines an override for loading texture buffers
  80995. * Return true to stop further extensions from loading this texture data
  80996. */
  80997. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80998. /**
  80999. * Defines an override for creating textures
  81000. * Return true to stop further extensions from loading this texture
  81001. */
  81002. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81003. /**
  81004. * Defines an override for loading shader strings
  81005. * Return true to stop further extensions from loading this shader data
  81006. */
  81007. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81008. /**
  81009. * Defines an override for loading materials
  81010. * Return true to stop further extensions from loading this material
  81011. */
  81012. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81013. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81014. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81015. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81016. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81017. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81018. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81019. private static LoadTextureBufferAsync;
  81020. private static CreateTextureAsync;
  81021. private static ApplyExtensions;
  81022. }
  81023. }
  81024. declare module BABYLON.GLTF1 {
  81025. /** @hidden */
  81026. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81027. private _bin;
  81028. constructor();
  81029. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81030. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81031. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81032. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81033. }
  81034. }
  81035. declare module BABYLON.GLTF1 {
  81036. /** @hidden */
  81037. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81038. constructor();
  81039. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81040. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81041. private _loadTexture;
  81042. }
  81043. }
  81044. declare module BABYLON.GLTF2.Loader {
  81045. /**
  81046. * Loader interface with an index field.
  81047. */
  81048. export interface IArrayItem {
  81049. /**
  81050. * The index of this item in the array.
  81051. */
  81052. index: number;
  81053. }
  81054. /**
  81055. * Loader interface with additional members.
  81056. */
  81057. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81058. /** @hidden */
  81059. _data?: Promise<ArrayBufferView>;
  81060. /** @hidden */
  81061. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81062. }
  81063. /**
  81064. * Loader interface with additional members.
  81065. */
  81066. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81067. }
  81068. /** @hidden */
  81069. export interface _IAnimationSamplerData {
  81070. input: Float32Array;
  81071. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81072. output: Float32Array;
  81073. }
  81074. /**
  81075. * Loader interface with additional members.
  81076. */
  81077. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81078. /** @hidden */
  81079. _data?: Promise<_IAnimationSamplerData>;
  81080. }
  81081. /**
  81082. * Loader interface with additional members.
  81083. */
  81084. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81085. channels: IAnimationChannel[];
  81086. samplers: IAnimationSampler[];
  81087. /** @hidden */
  81088. _babylonAnimationGroup?: AnimationGroup;
  81089. }
  81090. /**
  81091. * Loader interface with additional members.
  81092. */
  81093. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81094. /** @hidden */
  81095. _data?: Promise<ArrayBufferView>;
  81096. }
  81097. /**
  81098. * Loader interface with additional members.
  81099. */
  81100. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81101. /** @hidden */
  81102. _data?: Promise<ArrayBufferView>;
  81103. /** @hidden */
  81104. _babylonBuffer?: Promise<Buffer>;
  81105. }
  81106. /**
  81107. * Loader interface with additional members.
  81108. */
  81109. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81110. }
  81111. /**
  81112. * Loader interface with additional members.
  81113. */
  81114. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81115. /** @hidden */
  81116. _data?: Promise<ArrayBufferView>;
  81117. }
  81118. /**
  81119. * Loader interface with additional members.
  81120. */
  81121. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81122. }
  81123. /**
  81124. * Loader interface with additional members.
  81125. */
  81126. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81127. }
  81128. /**
  81129. * Loader interface with additional members.
  81130. */
  81131. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81132. baseColorTexture?: ITextureInfo;
  81133. metallicRoughnessTexture?: ITextureInfo;
  81134. }
  81135. /**
  81136. * Loader interface with additional members.
  81137. */
  81138. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81139. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81140. normalTexture?: IMaterialNormalTextureInfo;
  81141. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81142. emissiveTexture?: ITextureInfo;
  81143. /** @hidden */
  81144. _data?: {
  81145. [babylonDrawMode: number]: {
  81146. babylonMaterial: Material;
  81147. babylonMeshes: AbstractMesh[];
  81148. promise: Promise<void>;
  81149. };
  81150. };
  81151. }
  81152. /**
  81153. * Loader interface with additional members.
  81154. */
  81155. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81156. primitives: IMeshPrimitive[];
  81157. }
  81158. /**
  81159. * Loader interface with additional members.
  81160. */
  81161. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81162. /** @hidden */
  81163. _instanceData?: {
  81164. babylonSourceMesh: Mesh;
  81165. promise: Promise<any>;
  81166. };
  81167. }
  81168. /**
  81169. * Loader interface with additional members.
  81170. */
  81171. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81172. /**
  81173. * The parent glTF node.
  81174. */
  81175. parent?: INode;
  81176. /** @hidden */
  81177. _babylonTransformNode?: TransformNode;
  81178. /** @hidden */
  81179. _primitiveBabylonMeshes?: AbstractMesh[];
  81180. /** @hidden */
  81181. _babylonBones?: Bone[];
  81182. /** @hidden */
  81183. _numMorphTargets?: number;
  81184. }
  81185. /** @hidden */
  81186. export interface _ISamplerData {
  81187. noMipMaps: boolean;
  81188. samplingMode: number;
  81189. wrapU: number;
  81190. wrapV: number;
  81191. }
  81192. /**
  81193. * Loader interface with additional members.
  81194. */
  81195. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81196. /** @hidden */
  81197. _data?: _ISamplerData;
  81198. }
  81199. /**
  81200. * Loader interface with additional members.
  81201. */
  81202. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81203. }
  81204. /**
  81205. * Loader interface with additional members.
  81206. */
  81207. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81208. /** @hidden */
  81209. _data?: {
  81210. babylonSkeleton: Skeleton;
  81211. promise: Promise<void>;
  81212. };
  81213. }
  81214. /**
  81215. * Loader interface with additional members.
  81216. */
  81217. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81218. }
  81219. /**
  81220. * Loader interface with additional members.
  81221. */
  81222. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81223. }
  81224. /**
  81225. * Loader interface with additional members.
  81226. */
  81227. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81228. accessors?: IAccessor[];
  81229. animations?: IAnimation[];
  81230. buffers?: IBuffer[];
  81231. bufferViews?: IBufferView[];
  81232. cameras?: ICamera[];
  81233. images?: IImage[];
  81234. materials?: IMaterial[];
  81235. meshes?: IMesh[];
  81236. nodes?: INode[];
  81237. samplers?: ISampler[];
  81238. scenes?: IScene[];
  81239. skins?: ISkin[];
  81240. textures?: ITexture[];
  81241. }
  81242. }
  81243. declare module BABYLON.GLTF2 {
  81244. /**
  81245. * Interface for a glTF loader extension.
  81246. */
  81247. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81248. /**
  81249. * Called after the loader state changes to LOADING.
  81250. */
  81251. onLoading?(): void;
  81252. /**
  81253. * Called after the loader state changes to READY.
  81254. */
  81255. onReady?(): void;
  81256. /**
  81257. * Define this method to modify the default behavior when loading scenes.
  81258. * @param context The context when loading the asset
  81259. * @param scene The glTF scene property
  81260. * @returns A promise that resolves when the load is complete or null if not handled
  81261. */
  81262. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81263. /**
  81264. * Define this method to modify the default behavior when loading nodes.
  81265. * @param context The context when loading the asset
  81266. * @param node The glTF node property
  81267. * @param assign A function called synchronously after parsing the glTF properties
  81268. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81269. */
  81270. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81271. /**
  81272. * Define this method to modify the default behavior when loading cameras.
  81273. * @param context The context when loading the asset
  81274. * @param camera The glTF camera property
  81275. * @param assign A function called synchronously after parsing the glTF properties
  81276. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81277. */
  81278. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81279. /**
  81280. * @hidden
  81281. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81282. * @param context The context when loading the asset
  81283. * @param primitive The glTF mesh primitive property
  81284. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81285. */
  81286. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81287. /**
  81288. * @hidden
  81289. * Define this method to modify the default behavior when loading data for mesh primitives.
  81290. * @param context The context when loading the asset
  81291. * @param name The mesh name when loading the asset
  81292. * @param node The glTF node when loading the asset
  81293. * @param mesh The glTF mesh when loading the asset
  81294. * @param primitive The glTF mesh primitive property
  81295. * @param assign A function called synchronously after parsing the glTF properties
  81296. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81297. */
  81298. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81299. /**
  81300. * @hidden
  81301. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81302. * @param context The context when loading the asset
  81303. * @param material The glTF material property
  81304. * @param assign A function called synchronously after parsing the glTF properties
  81305. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81306. */
  81307. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81308. /**
  81309. * Define this method to modify the default behavior when creating materials.
  81310. * @param context The context when loading the asset
  81311. * @param material The glTF material property
  81312. * @param babylonDrawMode The draw mode for the Babylon material
  81313. * @returns The Babylon material or null if not handled
  81314. */
  81315. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81316. /**
  81317. * Define this method to modify the default behavior when loading material properties.
  81318. * @param context The context when loading the asset
  81319. * @param material The glTF material property
  81320. * @param babylonMaterial The Babylon material
  81321. * @returns A promise that resolves when the load is complete or null if not handled
  81322. */
  81323. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81324. /**
  81325. * Define this method to modify the default behavior when loading texture infos.
  81326. * @param context The context when loading the asset
  81327. * @param textureInfo The glTF texture info property
  81328. * @param assign A function called synchronously after parsing the glTF properties
  81329. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81330. */
  81331. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81332. /**
  81333. * @hidden
  81334. * Define this method to modify the default behavior when loading textures.
  81335. * @param context The context when loading the asset
  81336. * @param texture The glTF texture property
  81337. * @param assign A function called synchronously after parsing the glTF properties
  81338. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81339. */
  81340. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81341. /**
  81342. * Define this method to modify the default behavior when loading animations.
  81343. * @param context The context when loading the asset
  81344. * @param animation The glTF animation property
  81345. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81346. */
  81347. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81348. /**
  81349. * @hidden
  81350. * Define this method to modify the default behavior when loading skins.
  81351. * @param context The context when loading the asset
  81352. * @param node The glTF node property
  81353. * @param skin The glTF skin property
  81354. * @returns A promise that resolves when the load is complete or null if not handled
  81355. */
  81356. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81357. /**
  81358. * @hidden
  81359. * Define this method to modify the default behavior when loading uris.
  81360. * @param context The context when loading the asset
  81361. * @param property The glTF property associated with the uri
  81362. * @param uri The uri to load
  81363. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81364. */
  81365. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81366. /**
  81367. * Define this method to modify the default behavior when loading buffer views.
  81368. * @param context The context when loading the asset
  81369. * @param bufferView The glTF buffer view property
  81370. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81371. */
  81372. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81373. /**
  81374. * Define this method to modify the default behavior when loading buffers.
  81375. * @param context The context when loading the asset
  81376. * @param buffer The glTF buffer property
  81377. * @param byteOffset The byte offset to load
  81378. * @param byteLength The byte length to load
  81379. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81380. */
  81381. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81382. }
  81383. }
  81384. declare module BABYLON.GLTF2 {
  81385. /**
  81386. * Helper class for working with arrays when loading the glTF asset
  81387. */
  81388. export class ArrayItem {
  81389. /**
  81390. * Gets an item from the given array.
  81391. * @param context The context when loading the asset
  81392. * @param array The array to get the item from
  81393. * @param index The index to the array
  81394. * @returns The array item
  81395. */
  81396. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81397. /**
  81398. * Assign an `index` field to each item of the given array.
  81399. * @param array The array of items
  81400. */
  81401. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81402. }
  81403. /**
  81404. * The glTF 2.0 loader
  81405. */
  81406. export class GLTFLoader implements IGLTFLoader {
  81407. /** @hidden */
  81408. _completePromises: Promise<any>[];
  81409. /** @hidden */
  81410. _forAssetContainer: boolean;
  81411. /** Storage */
  81412. _babylonLights: Light[];
  81413. /** @hidden */
  81414. _disableInstancedMesh: number;
  81415. private _disposed;
  81416. private _parent;
  81417. private _state;
  81418. private _extensions;
  81419. private _rootUrl;
  81420. private _fileName;
  81421. private _uniqueRootUrl;
  81422. private _gltf;
  81423. private _bin;
  81424. private _babylonScene;
  81425. private _rootBabylonMesh;
  81426. private _defaultBabylonMaterialData;
  81427. private static _RegisteredExtensions;
  81428. /**
  81429. * The default glTF sampler.
  81430. */
  81431. static readonly DefaultSampler: ISampler;
  81432. /**
  81433. * Registers a loader extension.
  81434. * @param name The name of the loader extension.
  81435. * @param factory The factory function that creates the loader extension.
  81436. */
  81437. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81438. /**
  81439. * Unregisters a loader extension.
  81440. * @param name The name of the loader extension.
  81441. * @returns A boolean indicating whether the extension has been unregistered
  81442. */
  81443. static UnregisterExtension(name: string): boolean;
  81444. /**
  81445. * The loader state.
  81446. */
  81447. get state(): Nullable<GLTFLoaderState>;
  81448. /**
  81449. * The object that represents the glTF JSON.
  81450. */
  81451. get gltf(): IGLTF;
  81452. /**
  81453. * The BIN chunk of a binary glTF.
  81454. */
  81455. get bin(): Nullable<IDataBuffer>;
  81456. /**
  81457. * The parent file loader.
  81458. */
  81459. get parent(): GLTFFileLoader;
  81460. /**
  81461. * The Babylon scene when loading the asset.
  81462. */
  81463. get babylonScene(): Scene;
  81464. /**
  81465. * The root Babylon mesh when loading the asset.
  81466. */
  81467. get rootBabylonMesh(): Mesh;
  81468. /** @hidden */
  81469. constructor(parent: GLTFFileLoader);
  81470. /** @hidden */
  81471. dispose(): void;
  81472. /** @hidden */
  81473. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81474. /** @hidden */
  81475. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81476. private _loadAsync;
  81477. private _loadData;
  81478. private _setupData;
  81479. private _loadExtensions;
  81480. private _checkExtensions;
  81481. private _setState;
  81482. private _createRootNode;
  81483. /**
  81484. * Loads a glTF scene.
  81485. * @param context The context when loading the asset
  81486. * @param scene The glTF scene property
  81487. * @returns A promise that resolves when the load is complete
  81488. */
  81489. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81490. private _forEachPrimitive;
  81491. private _getMeshes;
  81492. private _getTransformNodes;
  81493. private _getSkeletons;
  81494. private _getAnimationGroups;
  81495. private _startAnimations;
  81496. /**
  81497. * Loads a glTF node.
  81498. * @param context The context when loading the asset
  81499. * @param node The glTF node property
  81500. * @param assign A function called synchronously after parsing the glTF properties
  81501. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81502. */
  81503. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81504. private _loadMeshAsync;
  81505. /**
  81506. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81507. * @param context The context when loading the asset
  81508. * @param name The mesh name when loading the asset
  81509. * @param node The glTF node when loading the asset
  81510. * @param mesh The glTF mesh when loading the asset
  81511. * @param primitive The glTF mesh primitive property
  81512. * @param assign A function called synchronously after parsing the glTF properties
  81513. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81514. */
  81515. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81516. private _loadVertexDataAsync;
  81517. private _createMorphTargets;
  81518. private _loadMorphTargetsAsync;
  81519. private _loadMorphTargetVertexDataAsync;
  81520. private static _LoadTransform;
  81521. private _loadSkinAsync;
  81522. private _loadBones;
  81523. private _loadBone;
  81524. private _loadSkinInverseBindMatricesDataAsync;
  81525. private _updateBoneMatrices;
  81526. private _getNodeMatrix;
  81527. /**
  81528. * Loads a glTF camera.
  81529. * @param context The context when loading the asset
  81530. * @param camera The glTF camera property
  81531. * @param assign A function called synchronously after parsing the glTF properties
  81532. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81533. */
  81534. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81535. private _loadAnimationsAsync;
  81536. /**
  81537. * Loads a glTF animation.
  81538. * @param context The context when loading the asset
  81539. * @param animation The glTF animation property
  81540. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81541. */
  81542. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81543. /**
  81544. * @hidden Loads a glTF animation channel.
  81545. * @param context The context when loading the asset
  81546. * @param animationContext The context of the animation when loading the asset
  81547. * @param animation The glTF animation property
  81548. * @param channel The glTF animation channel property
  81549. * @param babylonAnimationGroup The babylon animation group property
  81550. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81551. * @returns A void promise when the channel load is complete
  81552. */
  81553. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81554. private _loadAnimationSamplerAsync;
  81555. private _loadBufferAsync;
  81556. /**
  81557. * Loads a glTF buffer view.
  81558. * @param context The context when loading the asset
  81559. * @param bufferView The glTF buffer view property
  81560. * @returns A promise that resolves with the loaded data when the load is complete
  81561. */
  81562. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81563. private _loadAccessorAsync;
  81564. /** @hidden */
  81565. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81566. private _loadIndicesAccessorAsync;
  81567. private _loadVertexBufferViewAsync;
  81568. private _loadVertexAccessorAsync;
  81569. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81570. /** @hidden */
  81571. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81572. private _createDefaultMaterial;
  81573. /**
  81574. * Creates a Babylon material from a glTF material.
  81575. * @param context The context when loading the asset
  81576. * @param material The glTF material property
  81577. * @param babylonDrawMode The draw mode for the Babylon material
  81578. * @returns The Babylon material
  81579. */
  81580. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81581. /**
  81582. * Loads properties from a glTF material into a Babylon material.
  81583. * @param context The context when loading the asset
  81584. * @param material The glTF material property
  81585. * @param babylonMaterial The Babylon material
  81586. * @returns A promise that resolves when the load is complete
  81587. */
  81588. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81589. /**
  81590. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81591. * @param context The context when loading the asset
  81592. * @param material The glTF material property
  81593. * @param babylonMaterial The Babylon material
  81594. * @returns A promise that resolves when the load is complete
  81595. */
  81596. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81597. /**
  81598. * Loads the alpha properties from a glTF material into a Babylon material.
  81599. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81600. * @param context The context when loading the asset
  81601. * @param material The glTF material property
  81602. * @param babylonMaterial The Babylon material
  81603. */
  81604. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81605. /**
  81606. * Loads a glTF texture info.
  81607. * @param context The context when loading the asset
  81608. * @param textureInfo The glTF texture info property
  81609. * @param assign A function called synchronously after parsing the glTF properties
  81610. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81611. */
  81612. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81613. /** @hidden */
  81614. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81615. /** @hidden */
  81616. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81617. private _loadSampler;
  81618. /**
  81619. * Loads a glTF image.
  81620. * @param context The context when loading the asset
  81621. * @param image The glTF image property
  81622. * @returns A promise that resolves with the loaded data when the load is complete
  81623. */
  81624. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81625. /**
  81626. * Loads a glTF uri.
  81627. * @param context The context when loading the asset
  81628. * @param property The glTF property associated with the uri
  81629. * @param uri The base64 or relative uri
  81630. * @returns A promise that resolves with the loaded data when the load is complete
  81631. */
  81632. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81633. /**
  81634. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81635. * @param babylonObject the Babylon object with metadata
  81636. * @param pointer the JSON pointer
  81637. */
  81638. static AddPointerMetadata(babylonObject: {
  81639. metadata: any;
  81640. }, pointer: string): void;
  81641. private static _GetTextureWrapMode;
  81642. private static _GetTextureSamplingMode;
  81643. private static _GetTypedArrayConstructor;
  81644. private static _GetTypedArray;
  81645. private static _GetNumComponents;
  81646. private static _ValidateUri;
  81647. /** @hidden */
  81648. static _GetDrawMode(context: string, mode: number | undefined): number;
  81649. private _compileMaterialsAsync;
  81650. private _compileShadowGeneratorsAsync;
  81651. private _forEachExtensions;
  81652. private _applyExtensions;
  81653. private _extensionsOnLoading;
  81654. private _extensionsOnReady;
  81655. private _extensionsLoadSceneAsync;
  81656. private _extensionsLoadNodeAsync;
  81657. private _extensionsLoadCameraAsync;
  81658. private _extensionsLoadVertexDataAsync;
  81659. private _extensionsLoadMeshPrimitiveAsync;
  81660. private _extensionsLoadMaterialAsync;
  81661. private _extensionsCreateMaterial;
  81662. private _extensionsLoadMaterialPropertiesAsync;
  81663. private _extensionsLoadTextureInfoAsync;
  81664. private _extensionsLoadTextureAsync;
  81665. private _extensionsLoadAnimationAsync;
  81666. private _extensionsLoadSkinAsync;
  81667. private _extensionsLoadUriAsync;
  81668. private _extensionsLoadBufferViewAsync;
  81669. private _extensionsLoadBufferAsync;
  81670. /**
  81671. * Helper method called by a loader extension to load an glTF extension.
  81672. * @param context The context when loading the asset
  81673. * @param property The glTF property to load the extension from
  81674. * @param extensionName The name of the extension to load
  81675. * @param actionAsync The action to run
  81676. * @returns The promise returned by actionAsync or null if the extension does not exist
  81677. */
  81678. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81679. /**
  81680. * Helper method called by a loader extension to load a glTF extra.
  81681. * @param context The context when loading the asset
  81682. * @param property The glTF property to load the extra from
  81683. * @param extensionName The name of the extension to load
  81684. * @param actionAsync The action to run
  81685. * @returns The promise returned by actionAsync or null if the extra does not exist
  81686. */
  81687. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81688. /**
  81689. * Checks for presence of an extension.
  81690. * @param name The name of the extension to check
  81691. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81692. */
  81693. isExtensionUsed(name: string): boolean;
  81694. /**
  81695. * Increments the indentation level and logs a message.
  81696. * @param message The message to log
  81697. */
  81698. logOpen(message: string): void;
  81699. /**
  81700. * Decrements the indentation level.
  81701. */
  81702. logClose(): void;
  81703. /**
  81704. * Logs a message
  81705. * @param message The message to log
  81706. */
  81707. log(message: string): void;
  81708. /**
  81709. * Starts a performance counter.
  81710. * @param counterName The name of the performance counter
  81711. */
  81712. startPerformanceCounter(counterName: string): void;
  81713. /**
  81714. * Ends a performance counter.
  81715. * @param counterName The name of the performance counter
  81716. */
  81717. endPerformanceCounter(counterName: string): void;
  81718. }
  81719. }
  81720. declare module BABYLON.GLTF2.Loader.Extensions {
  81721. /** @hidden */
  81722. interface IEXTLightsImageBased_LightImageBased {
  81723. _babylonTexture?: BaseTexture;
  81724. _loaded?: Promise<void>;
  81725. }
  81726. /**
  81727. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81728. */
  81729. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81730. /**
  81731. * The name of this extension.
  81732. */
  81733. readonly name: string;
  81734. /**
  81735. * Defines whether this extension is enabled.
  81736. */
  81737. enabled: boolean;
  81738. private _loader;
  81739. private _lights?;
  81740. /** @hidden */
  81741. constructor(loader: GLTFLoader);
  81742. /** @hidden */
  81743. dispose(): void;
  81744. /** @hidden */
  81745. onLoading(): void;
  81746. /** @hidden */
  81747. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81748. private _loadLightAsync;
  81749. }
  81750. }
  81751. declare module BABYLON.GLTF2.Loader.Extensions {
  81752. /**
  81753. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81754. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81755. * !!! Experimental Extension Subject to Changes !!!
  81756. */
  81757. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81758. /**
  81759. * The name of this extension.
  81760. */
  81761. readonly name: string;
  81762. /**
  81763. * Defines whether this extension is enabled.
  81764. */
  81765. enabled: boolean;
  81766. private _loader;
  81767. /** @hidden */
  81768. constructor(loader: GLTFLoader);
  81769. /** @hidden */
  81770. dispose(): void;
  81771. /** @hidden */
  81772. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81773. }
  81774. }
  81775. declare module BABYLON.GLTF2.Loader.Extensions {
  81776. /**
  81777. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81778. */
  81779. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81780. /** The name of this extension. */
  81781. readonly name: string;
  81782. /** Defines whether this extension is enabled. */
  81783. enabled: boolean;
  81784. private _loader;
  81785. /** @hidden */
  81786. constructor(loader: GLTFLoader);
  81787. /** @hidden */
  81788. dispose(): void;
  81789. /** @hidden */
  81790. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81791. }
  81792. }
  81793. declare module BABYLON.GLTF2.Loader.Extensions {
  81794. /**
  81795. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81796. */
  81797. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81798. /**
  81799. * The name of this extension.
  81800. */
  81801. readonly name: string;
  81802. /**
  81803. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81804. */
  81805. dracoCompression?: DracoCompression;
  81806. /**
  81807. * Defines whether this extension is enabled.
  81808. */
  81809. enabled: boolean;
  81810. private _loader;
  81811. /** @hidden */
  81812. constructor(loader: GLTFLoader);
  81813. /** @hidden */
  81814. dispose(): void;
  81815. /** @hidden */
  81816. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81817. }
  81818. }
  81819. declare module BABYLON.GLTF2.Loader.Extensions {
  81820. /**
  81821. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81822. */
  81823. export class KHR_lights implements IGLTFLoaderExtension {
  81824. /**
  81825. * The name of this extension.
  81826. */
  81827. readonly name: string;
  81828. /**
  81829. * Defines whether this extension is enabled.
  81830. */
  81831. enabled: boolean;
  81832. private _loader;
  81833. private _lights?;
  81834. /** @hidden */
  81835. constructor(loader: GLTFLoader);
  81836. /** @hidden */
  81837. dispose(): void;
  81838. /** @hidden */
  81839. onLoading(): void;
  81840. /** @hidden */
  81841. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81842. }
  81843. }
  81844. declare module BABYLON.GLTF2.Loader.Extensions {
  81845. /**
  81846. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81847. */
  81848. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81849. /**
  81850. * The name of this extension.
  81851. */
  81852. readonly name: string;
  81853. /**
  81854. * Defines whether this extension is enabled.
  81855. */
  81856. enabled: boolean;
  81857. /**
  81858. * Defines a number that determines the order the extensions are applied.
  81859. */
  81860. order: number;
  81861. private _loader;
  81862. /** @hidden */
  81863. constructor(loader: GLTFLoader);
  81864. /** @hidden */
  81865. dispose(): void;
  81866. /** @hidden */
  81867. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81868. private _loadSpecularGlossinessPropertiesAsync;
  81869. }
  81870. }
  81871. declare module BABYLON.GLTF2.Loader.Extensions {
  81872. /**
  81873. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81874. */
  81875. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81876. /**
  81877. * The name of this extension.
  81878. */
  81879. readonly name: string;
  81880. /**
  81881. * Defines whether this extension is enabled.
  81882. */
  81883. enabled: boolean;
  81884. /**
  81885. * Defines a number that determines the order the extensions are applied.
  81886. */
  81887. order: number;
  81888. private _loader;
  81889. /** @hidden */
  81890. constructor(loader: GLTFLoader);
  81891. /** @hidden */
  81892. dispose(): void;
  81893. /** @hidden */
  81894. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81895. private _loadUnlitPropertiesAsync;
  81896. }
  81897. }
  81898. declare module BABYLON.GLTF2.Loader.Extensions {
  81899. /**
  81900. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81901. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81902. * !!! Experimental Extension Subject to Changes !!!
  81903. */
  81904. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81905. /**
  81906. * The name of this extension.
  81907. */
  81908. readonly name: string;
  81909. /**
  81910. * Defines whether this extension is enabled.
  81911. */
  81912. enabled: boolean;
  81913. /**
  81914. * Defines a number that determines the order the extensions are applied.
  81915. */
  81916. order: number;
  81917. private _loader;
  81918. /** @hidden */
  81919. constructor(loader: GLTFLoader);
  81920. /** @hidden */
  81921. dispose(): void;
  81922. /** @hidden */
  81923. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81924. private _loadClearCoatPropertiesAsync;
  81925. }
  81926. }
  81927. declare module BABYLON.GLTF2.Loader.Extensions {
  81928. /**
  81929. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81930. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81931. * !!! Experimental Extension Subject to Changes !!!
  81932. */
  81933. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81934. /**
  81935. * The name of this extension.
  81936. */
  81937. readonly name: string;
  81938. /**
  81939. * Defines whether this extension is enabled.
  81940. */
  81941. enabled: boolean;
  81942. /**
  81943. * Defines a number that determines the order the extensions are applied.
  81944. */
  81945. order: number;
  81946. private _loader;
  81947. /** @hidden */
  81948. constructor(loader: GLTFLoader);
  81949. /** @hidden */
  81950. dispose(): void;
  81951. /** @hidden */
  81952. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81953. private _loadSheenPropertiesAsync;
  81954. }
  81955. }
  81956. declare module BABYLON.GLTF2.Loader.Extensions {
  81957. /**
  81958. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81959. * !!! Experimental Extension Subject to Changes !!!
  81960. */
  81961. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81962. /**
  81963. * The name of this extension.
  81964. */
  81965. readonly name: string;
  81966. /**
  81967. * Defines whether this extension is enabled.
  81968. */
  81969. enabled: boolean;
  81970. /**
  81971. * Defines a number that determines the order the extensions are applied.
  81972. */
  81973. order: number;
  81974. private _loader;
  81975. /** @hidden */
  81976. constructor(loader: GLTFLoader);
  81977. /** @hidden */
  81978. dispose(): void;
  81979. /** @hidden */
  81980. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81981. private _loadSpecularPropertiesAsync;
  81982. }
  81983. }
  81984. declare module BABYLON.GLTF2.Loader.Extensions {
  81985. /**
  81986. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81987. * !!! Experimental Extension Subject to Changes !!!
  81988. */
  81989. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81990. /**
  81991. * Default ior Value from the spec.
  81992. */
  81993. private static readonly _DEFAULT_IOR;
  81994. /**
  81995. * The name of this extension.
  81996. */
  81997. readonly name: string;
  81998. /**
  81999. * Defines whether this extension is enabled.
  82000. */
  82001. enabled: boolean;
  82002. /**
  82003. * Defines a number that determines the order the extensions are applied.
  82004. */
  82005. order: number;
  82006. private _loader;
  82007. /** @hidden */
  82008. constructor(loader: GLTFLoader);
  82009. /** @hidden */
  82010. dispose(): void;
  82011. /** @hidden */
  82012. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82013. private _loadIorPropertiesAsync;
  82014. }
  82015. }
  82016. declare module BABYLON.GLTF2.Loader.Extensions {
  82017. /**
  82018. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82019. * !!! Experimental Extension Subject to Changes !!!
  82020. */
  82021. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82022. /**
  82023. * The name of this extension.
  82024. */
  82025. readonly name: string;
  82026. /**
  82027. * Defines whether this extension is enabled.
  82028. */
  82029. enabled: boolean;
  82030. private _loader;
  82031. private _variants?;
  82032. /** @hidden */
  82033. constructor(loader: GLTFLoader);
  82034. /** @hidden */
  82035. dispose(): void;
  82036. /**
  82037. * Gets the list of available variant names for this asset.
  82038. * @param rootMesh The glTF root mesh
  82039. * @returns the list of all the variant names for this model
  82040. */
  82041. static GetAvailableVariants(rootMesh: Mesh): string[];
  82042. /**
  82043. * Gets the list of available variant names for this asset.
  82044. * @param rootMesh The glTF root mesh
  82045. * @returns the list of all the variant names for this model
  82046. */
  82047. getAvailableVariants(rootMesh: Mesh): string[];
  82048. /**
  82049. * Select a variant given a variant name or a list of variant names.
  82050. * @param rootMesh The glTF root mesh
  82051. * @param variantName The variant name(s) to select.
  82052. */
  82053. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82054. /**
  82055. * Select a variant given a variant name or a list of variant names.
  82056. * @param rootMesh The glTF root mesh
  82057. * @param variantName The variant name(s) to select.
  82058. */
  82059. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82060. /**
  82061. * Reset back to the original before selecting a variant.
  82062. * @param rootMesh The glTF root mesh
  82063. */
  82064. static Reset(rootMesh: Mesh): void;
  82065. /**
  82066. * Reset back to the original before selecting a variant.
  82067. * @param rootMesh The glTF root mesh
  82068. */
  82069. reset(rootMesh: Mesh): void;
  82070. /**
  82071. * Gets the last selected variant name(s) or null if original.
  82072. * @param rootMesh The glTF root mesh
  82073. * @returns The selected variant name(s).
  82074. */
  82075. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82076. /**
  82077. * Gets the last selected variant name(s) or null if original.
  82078. * @param rootMesh The glTF root mesh
  82079. * @returns The selected variant name(s).
  82080. */
  82081. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82082. private static _GetExtensionMetadata;
  82083. /** @hidden */
  82084. onLoading(): void;
  82085. /** @hidden */
  82086. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82087. }
  82088. }
  82089. declare module BABYLON.GLTF2.Loader.Extensions {
  82090. /**
  82091. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82092. * !!! Experimental Extension Subject to Changes !!!
  82093. */
  82094. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82095. /**
  82096. * The name of this extension.
  82097. */
  82098. readonly name: string;
  82099. /**
  82100. * Defines whether this extension is enabled.
  82101. */
  82102. enabled: boolean;
  82103. /**
  82104. * Defines a number that determines the order the extensions are applied.
  82105. */
  82106. order: number;
  82107. private _loader;
  82108. /** @hidden */
  82109. constructor(loader: GLTFLoader);
  82110. /** @hidden */
  82111. dispose(): void;
  82112. /** @hidden */
  82113. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82114. private _loadTransparentPropertiesAsync;
  82115. }
  82116. }
  82117. declare module BABYLON.GLTF2.Loader.Extensions {
  82118. /**
  82119. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82120. */
  82121. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82122. /**
  82123. * The name of this extension.
  82124. */
  82125. readonly name: string;
  82126. /**
  82127. * Defines whether this extension is enabled.
  82128. */
  82129. enabled: boolean;
  82130. /** @hidden */
  82131. constructor(loader: GLTFLoader);
  82132. /** @hidden */
  82133. dispose(): void;
  82134. }
  82135. }
  82136. declare module BABYLON.GLTF2.Loader.Extensions {
  82137. /**
  82138. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82139. * !!! Experimental Extension Subject to Changes !!!
  82140. */
  82141. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82142. /** The name of this extension. */
  82143. readonly name: string;
  82144. /** Defines whether this extension is enabled. */
  82145. enabled: boolean;
  82146. private _loader;
  82147. /** @hidden */
  82148. constructor(loader: GLTFLoader);
  82149. /** @hidden */
  82150. dispose(): void;
  82151. /** @hidden */
  82152. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82153. }
  82154. }
  82155. declare module BABYLON.GLTF2.Loader.Extensions {
  82156. /**
  82157. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82158. */
  82159. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82160. /**
  82161. * The name of this extension.
  82162. */
  82163. readonly name: string;
  82164. /**
  82165. * Defines whether this extension is enabled.
  82166. */
  82167. enabled: boolean;
  82168. private _loader;
  82169. /** @hidden */
  82170. constructor(loader: GLTFLoader);
  82171. /** @hidden */
  82172. dispose(): void;
  82173. /** @hidden */
  82174. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82175. }
  82176. }
  82177. declare module BABYLON.GLTF2.Loader.Extensions {
  82178. /**
  82179. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82180. * !!! Experimental Extension Subject to Changes !!!
  82181. */
  82182. export class KHR_xmp implements IGLTFLoaderExtension {
  82183. /**
  82184. * The name of this extension.
  82185. */
  82186. readonly name: string;
  82187. /**
  82188. * Defines whether this extension is enabled.
  82189. */
  82190. enabled: boolean;
  82191. /**
  82192. * Defines a number that determines the order the extensions are applied.
  82193. */
  82194. order: number;
  82195. private _loader;
  82196. /** @hidden */
  82197. constructor(loader: GLTFLoader);
  82198. /** @hidden */
  82199. dispose(): void;
  82200. /**
  82201. * Called after the loader state changes to LOADING.
  82202. */
  82203. onLoading(): void;
  82204. }
  82205. }
  82206. declare module BABYLON.GLTF2.Loader.Extensions {
  82207. /**
  82208. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82209. */
  82210. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82211. /**
  82212. * The name of this extension.
  82213. */
  82214. readonly name: string;
  82215. /**
  82216. * Defines whether this extension is enabled.
  82217. */
  82218. enabled: boolean;
  82219. private _loader;
  82220. private _clips;
  82221. private _emitters;
  82222. /** @hidden */
  82223. constructor(loader: GLTFLoader);
  82224. /** @hidden */
  82225. dispose(): void;
  82226. /** @hidden */
  82227. onLoading(): void;
  82228. /** @hidden */
  82229. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82230. /** @hidden */
  82231. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82232. /** @hidden */
  82233. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82234. private _loadClipAsync;
  82235. private _loadEmitterAsync;
  82236. private _getEventAction;
  82237. private _loadAnimationEventAsync;
  82238. }
  82239. }
  82240. declare module BABYLON.GLTF2.Loader.Extensions {
  82241. /**
  82242. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82243. */
  82244. export class MSFT_lod implements IGLTFLoaderExtension {
  82245. /**
  82246. * The name of this extension.
  82247. */
  82248. readonly name: string;
  82249. /**
  82250. * Defines whether this extension is enabled.
  82251. */
  82252. enabled: boolean;
  82253. /**
  82254. * Defines a number that determines the order the extensions are applied.
  82255. */
  82256. order: number;
  82257. /**
  82258. * Maximum number of LODs to load, starting from the lowest LOD.
  82259. */
  82260. maxLODsToLoad: number;
  82261. /**
  82262. * Observable raised when all node LODs of one level are loaded.
  82263. * The event data is the index of the loaded LOD starting from zero.
  82264. * Dispose the loader to cancel the loading of the next level of LODs.
  82265. */
  82266. onNodeLODsLoadedObservable: Observable<number>;
  82267. /**
  82268. * Observable raised when all material LODs of one level are loaded.
  82269. * The event data is the index of the loaded LOD starting from zero.
  82270. * Dispose the loader to cancel the loading of the next level of LODs.
  82271. */
  82272. onMaterialLODsLoadedObservable: Observable<number>;
  82273. private _loader;
  82274. private _bufferLODs;
  82275. private _nodeIndexLOD;
  82276. private _nodeSignalLODs;
  82277. private _nodePromiseLODs;
  82278. private _nodeBufferLODs;
  82279. private _materialIndexLOD;
  82280. private _materialSignalLODs;
  82281. private _materialPromiseLODs;
  82282. private _materialBufferLODs;
  82283. /** @hidden */
  82284. constructor(loader: GLTFLoader);
  82285. /** @hidden */
  82286. dispose(): void;
  82287. /** @hidden */
  82288. onReady(): void;
  82289. /** @hidden */
  82290. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82291. /** @hidden */
  82292. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82293. /** @hidden */
  82294. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82295. /** @hidden */
  82296. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82297. /** @hidden */
  82298. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82299. private _loadBufferLOD;
  82300. /**
  82301. * Gets an array of LOD properties from lowest to highest.
  82302. */
  82303. private _getLODs;
  82304. private _disposeTransformNode;
  82305. private _disposeMaterials;
  82306. }
  82307. }
  82308. declare module BABYLON.GLTF2.Loader.Extensions {
  82309. /** @hidden */
  82310. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82311. readonly name: string;
  82312. enabled: boolean;
  82313. private _loader;
  82314. constructor(loader: GLTFLoader);
  82315. dispose(): void;
  82316. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82317. }
  82318. }
  82319. declare module BABYLON.GLTF2.Loader.Extensions {
  82320. /** @hidden */
  82321. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82322. readonly name: string;
  82323. enabled: boolean;
  82324. private _loader;
  82325. constructor(loader: GLTFLoader);
  82326. dispose(): void;
  82327. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82328. }
  82329. }
  82330. declare module BABYLON.GLTF2.Loader.Extensions {
  82331. /**
  82332. * Store glTF extras (if present) in BJS objects' metadata
  82333. */
  82334. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82335. /**
  82336. * The name of this extension.
  82337. */
  82338. readonly name: string;
  82339. /**
  82340. * Defines whether this extension is enabled.
  82341. */
  82342. enabled: boolean;
  82343. private _loader;
  82344. private _assignExtras;
  82345. /** @hidden */
  82346. constructor(loader: GLTFLoader);
  82347. /** @hidden */
  82348. dispose(): void;
  82349. /** @hidden */
  82350. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82351. /** @hidden */
  82352. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82353. /** @hidden */
  82354. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82355. }
  82356. }
  82357. declare module BABYLON {
  82358. /**
  82359. * Class reading and parsing the MTL file bundled with the obj file.
  82360. */
  82361. export class MTLFileLoader {
  82362. /**
  82363. * Invert Y-Axis of referenced textures on load
  82364. */
  82365. static INVERT_TEXTURE_Y: boolean;
  82366. /**
  82367. * All material loaded from the mtl will be set here
  82368. */
  82369. materials: StandardMaterial[];
  82370. /**
  82371. * This function will read the mtl file and create each material described inside
  82372. * This function could be improve by adding :
  82373. * -some component missing (Ni, Tf...)
  82374. * -including the specific options available
  82375. *
  82376. * @param scene defines the scene the material will be created in
  82377. * @param data defines the mtl data to parse
  82378. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82379. * @param forAssetContainer defines if the material should be registered in the scene
  82380. */
  82381. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82382. /**
  82383. * Gets the texture for the material.
  82384. *
  82385. * If the material is imported from input file,
  82386. * We sanitize the url to ensure it takes the textre from aside the material.
  82387. *
  82388. * @param rootUrl The root url to load from
  82389. * @param value The value stored in the mtl
  82390. * @return The Texture
  82391. */
  82392. private static _getTexture;
  82393. }
  82394. }
  82395. declare module BABYLON {
  82396. /**
  82397. * Options for loading OBJ/MTL files
  82398. */
  82399. type MeshLoadOptions = {
  82400. /**
  82401. * Defines if UVs are optimized by default during load.
  82402. */
  82403. OptimizeWithUV: boolean;
  82404. /**
  82405. * Defines custom scaling of UV coordinates of loaded meshes.
  82406. */
  82407. UVScaling: Vector2;
  82408. /**
  82409. * Invert model on y-axis (does a model scaling inversion)
  82410. */
  82411. InvertY: boolean;
  82412. /**
  82413. * Invert Y-Axis of referenced textures on load
  82414. */
  82415. InvertTextureY: boolean;
  82416. /**
  82417. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82418. */
  82419. ImportVertexColors: boolean;
  82420. /**
  82421. * Compute the normals for the model, even if normals are present in the file.
  82422. */
  82423. ComputeNormals: boolean;
  82424. /**
  82425. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82426. */
  82427. SkipMaterials: boolean;
  82428. /**
  82429. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82430. */
  82431. MaterialLoadingFailsSilently: boolean;
  82432. };
  82433. /**
  82434. * OBJ file type loader.
  82435. * This is a babylon scene loader plugin.
  82436. */
  82437. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82438. /**
  82439. * Defines if UVs are optimized by default during load.
  82440. */
  82441. static OPTIMIZE_WITH_UV: boolean;
  82442. /**
  82443. * Invert model on y-axis (does a model scaling inversion)
  82444. */
  82445. static INVERT_Y: boolean;
  82446. /**
  82447. * Invert Y-Axis of referenced textures on load
  82448. */
  82449. static get INVERT_TEXTURE_Y(): boolean;
  82450. static set INVERT_TEXTURE_Y(value: boolean);
  82451. /**
  82452. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82453. */
  82454. static IMPORT_VERTEX_COLORS: boolean;
  82455. /**
  82456. * Compute the normals for the model, even if normals are present in the file.
  82457. */
  82458. static COMPUTE_NORMALS: boolean;
  82459. /**
  82460. * Defines custom scaling of UV coordinates of loaded meshes.
  82461. */
  82462. static UV_SCALING: Vector2;
  82463. /**
  82464. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82465. */
  82466. static SKIP_MATERIALS: boolean;
  82467. /**
  82468. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82469. *
  82470. * Defaults to true for backwards compatibility.
  82471. */
  82472. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82473. /**
  82474. * Defines the name of the plugin.
  82475. */
  82476. name: string;
  82477. /**
  82478. * Defines the extension the plugin is able to load.
  82479. */
  82480. extensions: string;
  82481. /** @hidden */
  82482. obj: RegExp;
  82483. /** @hidden */
  82484. group: RegExp;
  82485. /** @hidden */
  82486. mtllib: RegExp;
  82487. /** @hidden */
  82488. usemtl: RegExp;
  82489. /** @hidden */
  82490. smooth: RegExp;
  82491. /** @hidden */
  82492. vertexPattern: RegExp;
  82493. /** @hidden */
  82494. normalPattern: RegExp;
  82495. /** @hidden */
  82496. uvPattern: RegExp;
  82497. /** @hidden */
  82498. facePattern1: RegExp;
  82499. /** @hidden */
  82500. facePattern2: RegExp;
  82501. /** @hidden */
  82502. facePattern3: RegExp;
  82503. /** @hidden */
  82504. facePattern4: RegExp;
  82505. /** @hidden */
  82506. facePattern5: RegExp;
  82507. private _forAssetContainer;
  82508. private _meshLoadOptions;
  82509. /**
  82510. * Creates loader for .OBJ files
  82511. *
  82512. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82513. */
  82514. constructor(meshLoadOptions?: MeshLoadOptions);
  82515. private static get currentMeshLoadOptions();
  82516. /**
  82517. * Calls synchronously the MTL file attached to this obj.
  82518. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82519. * Without this function materials are not displayed in the first frame (but displayed after).
  82520. * In consequence it is impossible to get material information in your HTML file
  82521. *
  82522. * @param url The URL of the MTL file
  82523. * @param rootUrl
  82524. * @param onSuccess Callback function to be called when the MTL file is loaded
  82525. * @private
  82526. */
  82527. private _loadMTL;
  82528. /**
  82529. * Instantiates a OBJ file loader plugin.
  82530. * @returns the created plugin
  82531. */
  82532. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82533. /**
  82534. * If the data string can be loaded directly.
  82535. *
  82536. * @param data string containing the file data
  82537. * @returns if the data can be loaded directly
  82538. */
  82539. canDirectLoad(data: string): boolean;
  82540. /**
  82541. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82542. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82543. * @param scene the scene the meshes should be added to
  82544. * @param data the OBJ data to load
  82545. * @param rootUrl root url to load from
  82546. * @param onProgress event that fires when loading progress has occured
  82547. * @param fileName Defines the name of the file to load
  82548. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82549. */
  82550. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82551. meshes: AbstractMesh[];
  82552. particleSystems: IParticleSystem[];
  82553. skeletons: Skeleton[];
  82554. animationGroups: AnimationGroup[];
  82555. }>;
  82556. /**
  82557. * Imports all objects from the loaded OBJ data and adds them to the scene
  82558. * @param scene the scene the objects should be added to
  82559. * @param data the OBJ data to load
  82560. * @param rootUrl root url to load from
  82561. * @param onProgress event that fires when loading progress has occured
  82562. * @param fileName Defines the name of the file to load
  82563. * @returns a promise which completes when objects have been loaded to the scene
  82564. */
  82565. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82566. /**
  82567. * Load into an asset container.
  82568. * @param scene The scene to load into
  82569. * @param data The data to import
  82570. * @param rootUrl The root url for scene and resources
  82571. * @param onProgress The callback when the load progresses
  82572. * @param fileName Defines the name of the file to load
  82573. * @returns The loaded asset container
  82574. */
  82575. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82576. /**
  82577. * Read the OBJ file and create an Array of meshes.
  82578. * Each mesh contains all information given by the OBJ and the MTL file.
  82579. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82580. *
  82581. * @param meshesNames
  82582. * @param scene Scene The scene where are displayed the data
  82583. * @param data String The content of the obj file
  82584. * @param rootUrl String The path to the folder
  82585. * @returns Array<AbstractMesh>
  82586. * @private
  82587. */
  82588. private _parseSolid;
  82589. }
  82590. }
  82591. declare module BABYLON {
  82592. /**
  82593. * STL file type loader.
  82594. * This is a babylon scene loader plugin.
  82595. */
  82596. export class STLFileLoader implements ISceneLoaderPlugin {
  82597. /** @hidden */
  82598. solidPattern: RegExp;
  82599. /** @hidden */
  82600. facetsPattern: RegExp;
  82601. /** @hidden */
  82602. normalPattern: RegExp;
  82603. /** @hidden */
  82604. vertexPattern: RegExp;
  82605. /**
  82606. * Defines the name of the plugin.
  82607. */
  82608. name: string;
  82609. /**
  82610. * Defines the extensions the stl loader is able to load.
  82611. * force data to come in as an ArrayBuffer
  82612. * we'll convert to string if it looks like it's an ASCII .stl
  82613. */
  82614. extensions: ISceneLoaderPluginExtensions;
  82615. /**
  82616. * Import meshes into a scene.
  82617. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82618. * @param scene The scene to import into
  82619. * @param data The data to import
  82620. * @param rootUrl The root url for scene and resources
  82621. * @param meshes The meshes array to import into
  82622. * @param particleSystems The particle systems array to import into
  82623. * @param skeletons The skeletons array to import into
  82624. * @param onError The callback when import fails
  82625. * @returns True if successful or false otherwise
  82626. */
  82627. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82628. /**
  82629. * Load into a scene.
  82630. * @param scene The scene to load into
  82631. * @param data The data to import
  82632. * @param rootUrl The root url for scene and resources
  82633. * @param onError The callback when import fails
  82634. * @returns true if successful or false otherwise
  82635. */
  82636. load(scene: Scene, data: any, rootUrl: string): boolean;
  82637. /**
  82638. * Load into an asset container.
  82639. * @param scene The scene to load into
  82640. * @param data The data to import
  82641. * @param rootUrl The root url for scene and resources
  82642. * @param onError The callback when import fails
  82643. * @returns The loaded asset container
  82644. */
  82645. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82646. private _isBinary;
  82647. private _parseBinary;
  82648. private _parseASCII;
  82649. }
  82650. }
  82651. declare module BABYLON {
  82652. /**
  82653. * Class for generating OBJ data from a Babylon scene.
  82654. */
  82655. export class OBJExport {
  82656. /**
  82657. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82658. * @param mesh defines the list of meshes to serialize
  82659. * @param materials defines if materials should be exported
  82660. * @param matlibname defines the name of the associated mtl file
  82661. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82662. * @returns the OBJ content
  82663. */
  82664. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82665. /**
  82666. * Exports the material(s) of a mesh in .MTL file format (text)
  82667. * @param mesh defines the mesh to extract the material from
  82668. * @returns the mtl content
  82669. */
  82670. static MTL(mesh: Mesh): string;
  82671. }
  82672. }
  82673. declare module BABYLON {
  82674. /** @hidden */
  82675. export var __IGLTFExporterExtension: number;
  82676. /**
  82677. * Interface for extending the exporter
  82678. * @hidden
  82679. */
  82680. export interface IGLTFExporterExtension {
  82681. /**
  82682. * The name of this extension
  82683. */
  82684. readonly name: string;
  82685. /**
  82686. * Defines whether this extension is enabled
  82687. */
  82688. enabled: boolean;
  82689. /**
  82690. * Defines whether this extension is required
  82691. */
  82692. required: boolean;
  82693. }
  82694. }
  82695. declare module BABYLON.GLTF2.Exporter {
  82696. /** @hidden */
  82697. export var __IGLTFExporterExtensionV2: number;
  82698. /**
  82699. * Interface for a glTF exporter extension
  82700. * @hidden
  82701. */
  82702. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82703. /**
  82704. * Define this method to modify the default behavior before exporting a texture
  82705. * @param context The context when loading the asset
  82706. * @param babylonTexture The Babylon.js texture
  82707. * @param mimeType The mime-type of the generated image
  82708. * @returns A promise that resolves with the exported texture
  82709. */
  82710. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82711. /**
  82712. * Define this method to get notified when a texture info is created
  82713. * @param context The context when loading the asset
  82714. * @param textureInfo The glTF texture info
  82715. * @param babylonTexture The Babylon.js texture
  82716. */
  82717. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82718. /**
  82719. * Define this method to modify the default behavior when exporting texture info
  82720. * @param context The context when loading the asset
  82721. * @param meshPrimitive glTF mesh primitive
  82722. * @param babylonSubMesh Babylon submesh
  82723. * @param binaryWriter glTF serializer binary writer instance
  82724. * @returns nullable IMeshPrimitive promise
  82725. */
  82726. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82727. /**
  82728. * Define this method to modify the default behavior when exporting a node
  82729. * @param context The context when exporting the node
  82730. * @param node glTF node
  82731. * @param babylonNode BabylonJS node
  82732. * @returns nullable INode promise
  82733. */
  82734. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82735. [key: number]: number;
  82736. }): Promise<Nullable<INode>>;
  82737. /**
  82738. * Define this method to modify the default behavior when exporting a material
  82739. * @param material glTF material
  82740. * @param babylonMaterial BabylonJS material
  82741. * @returns nullable IMaterial promise
  82742. */
  82743. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82744. /**
  82745. * Define this method to return additional textures to export from a material
  82746. * @param material glTF material
  82747. * @param babylonMaterial BabylonJS material
  82748. * @returns List of textures
  82749. */
  82750. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82751. /** Gets a boolean indicating that this extension was used */
  82752. wasUsed: boolean;
  82753. /** Gets a boolean indicating that this extension is required for the file to work */
  82754. required: boolean;
  82755. /**
  82756. * Called after the exporter state changes to EXPORTING
  82757. */
  82758. onExporting?(): void;
  82759. }
  82760. }
  82761. declare module BABYLON.GLTF2.Exporter {
  82762. /**
  82763. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82764. * @hidden
  82765. */
  82766. export class _GLTFMaterialExporter {
  82767. /**
  82768. * Represents the dielectric specular values for R, G and B
  82769. */
  82770. private static readonly _DielectricSpecular;
  82771. /**
  82772. * Allows the maximum specular power to be defined for material calculations
  82773. */
  82774. private static readonly _MaxSpecularPower;
  82775. /**
  82776. * Mapping to store textures
  82777. */
  82778. private _textureMap;
  82779. /**
  82780. * Numeric tolerance value
  82781. */
  82782. private static readonly _Epsilon;
  82783. /**
  82784. * Reference to the glTF Exporter
  82785. */
  82786. private _exporter;
  82787. constructor(exporter: _Exporter);
  82788. /**
  82789. * Specifies if two colors are approximately equal in value
  82790. * @param color1 first color to compare to
  82791. * @param color2 second color to compare to
  82792. * @param epsilon threshold value
  82793. */
  82794. private static FuzzyEquals;
  82795. /**
  82796. * Gets the materials from a Babylon scene and converts them to glTF materials
  82797. * @param scene babylonjs scene
  82798. * @param mimeType texture mime type
  82799. * @param images array of images
  82800. * @param textures array of textures
  82801. * @param materials array of materials
  82802. * @param imageData mapping of texture names to base64 textures
  82803. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82804. */
  82805. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82806. /**
  82807. * Makes a copy of the glTF material without the texture parameters
  82808. * @param originalMaterial original glTF material
  82809. * @returns glTF material without texture parameters
  82810. */
  82811. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82812. /**
  82813. * Specifies if the material has any texture parameters present
  82814. * @param material glTF Material
  82815. * @returns boolean specifying if texture parameters are present
  82816. */
  82817. _hasTexturesPresent(material: IMaterial): boolean;
  82818. /**
  82819. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82820. * @param babylonStandardMaterial
  82821. * @returns glTF Metallic Roughness Material representation
  82822. */
  82823. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82824. /**
  82825. * Computes the metallic factor
  82826. * @param diffuse diffused value
  82827. * @param specular specular value
  82828. * @param oneMinusSpecularStrength one minus the specular strength
  82829. * @returns metallic value
  82830. */
  82831. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82832. /**
  82833. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82834. * @param glTFMaterial glTF material
  82835. * @param babylonMaterial Babylon material
  82836. */
  82837. private static _SetAlphaMode;
  82838. /**
  82839. * Converts a Babylon Standard Material to a glTF Material
  82840. * @param babylonStandardMaterial BJS Standard Material
  82841. * @param mimeType mime type to use for the textures
  82842. * @param images array of glTF image interfaces
  82843. * @param textures array of glTF texture interfaces
  82844. * @param materials array of glTF material interfaces
  82845. * @param imageData map of image file name to data
  82846. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82847. */
  82848. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82849. private _finishMaterial;
  82850. /**
  82851. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82852. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82853. * @param mimeType mime type to use for the textures
  82854. * @param images array of glTF image interfaces
  82855. * @param textures array of glTF texture interfaces
  82856. * @param materials array of glTF material interfaces
  82857. * @param imageData map of image file name to data
  82858. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82859. */
  82860. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82861. /**
  82862. * Converts an image typed array buffer to a base64 image
  82863. * @param buffer typed array buffer
  82864. * @param width width of the image
  82865. * @param height height of the image
  82866. * @param mimeType mimetype of the image
  82867. * @returns base64 image string
  82868. */
  82869. private _createBase64FromCanvasAsync;
  82870. /**
  82871. * Generates a white texture based on the specified width and height
  82872. * @param width width of the texture in pixels
  82873. * @param height height of the texture in pixels
  82874. * @param scene babylonjs scene
  82875. * @returns white texture
  82876. */
  82877. private _createWhiteTexture;
  82878. /**
  82879. * 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
  82880. * @param texture1 first texture to resize
  82881. * @param texture2 second texture to resize
  82882. * @param scene babylonjs scene
  82883. * @returns resized textures or null
  82884. */
  82885. private _resizeTexturesToSameDimensions;
  82886. /**
  82887. * Converts an array of pixels to a Float32Array
  82888. * Throws an error if the pixel format is not supported
  82889. * @param pixels - array buffer containing pixel values
  82890. * @returns Float32 of pixels
  82891. */
  82892. private _convertPixelArrayToFloat32;
  82893. /**
  82894. * Convert Specular Glossiness Textures to Metallic Roughness
  82895. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82896. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82897. * @param diffuseTexture texture used to store diffuse information
  82898. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82899. * @param factors specular glossiness material factors
  82900. * @param mimeType the mime type to use for the texture
  82901. * @returns pbr metallic roughness interface or null
  82902. */
  82903. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82904. /**
  82905. * Converts specular glossiness material properties to metallic roughness
  82906. * @param specularGlossiness interface with specular glossiness material properties
  82907. * @returns interface with metallic roughness material properties
  82908. */
  82909. private _convertSpecularGlossinessToMetallicRoughness;
  82910. /**
  82911. * Calculates the surface reflectance, independent of lighting conditions
  82912. * @param color Color source to calculate brightness from
  82913. * @returns number representing the perceived brightness, or zero if color is undefined
  82914. */
  82915. private _getPerceivedBrightness;
  82916. /**
  82917. * Returns the maximum color component value
  82918. * @param color
  82919. * @returns maximum color component value, or zero if color is null or undefined
  82920. */
  82921. private _getMaxComponent;
  82922. /**
  82923. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82924. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82925. * @param mimeType mime type to use for the textures
  82926. * @param images array of glTF image interfaces
  82927. * @param textures array of glTF texture interfaces
  82928. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82929. * @param imageData map of image file name to data
  82930. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82931. * @returns glTF PBR Metallic Roughness factors
  82932. */
  82933. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82934. private _getGLTFTextureSampler;
  82935. private _getGLTFTextureWrapMode;
  82936. private _getGLTFTextureWrapModesSampler;
  82937. /**
  82938. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82939. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82940. * @param mimeType mime type to use for the textures
  82941. * @param images array of glTF image interfaces
  82942. * @param textures array of glTF texture interfaces
  82943. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82944. * @param imageData map of image file name to data
  82945. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82946. * @returns glTF PBR Metallic Roughness factors
  82947. */
  82948. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82949. /**
  82950. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82951. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82952. * @param mimeType mime type to use for the textures
  82953. * @param images array of glTF image interfaces
  82954. * @param textures array of glTF texture interfaces
  82955. * @param materials array of glTF material interfaces
  82956. * @param imageData map of image file name to data
  82957. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82958. */
  82959. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82960. private setMetallicRoughnessPbrMaterial;
  82961. private getPixelsFromTexture;
  82962. /**
  82963. * Extracts a texture from a Babylon texture into file data and glTF data
  82964. * @param babylonTexture Babylon texture to extract
  82965. * @param mimeType Mime Type of the babylonTexture
  82966. * @return glTF texture info, or null if the texture format is not supported
  82967. */
  82968. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82969. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82970. /**
  82971. * Builds a texture from base64 string
  82972. * @param base64Texture base64 texture string
  82973. * @param baseTextureName Name to use for the texture
  82974. * @param mimeType image mime type for the texture
  82975. * @param images array of images
  82976. * @param textures array of textures
  82977. * @param imageData map of image data
  82978. * @returns glTF texture info, or null if the texture format is not supported
  82979. */
  82980. private _getTextureInfoFromBase64;
  82981. }
  82982. }
  82983. declare module BABYLON {
  82984. /**
  82985. * Class for holding and downloading glTF file data
  82986. */
  82987. export class GLTFData {
  82988. /**
  82989. * Object which contains the file name as the key and its data as the value
  82990. */
  82991. glTFFiles: {
  82992. [fileName: string]: string | Blob;
  82993. };
  82994. /**
  82995. * Initializes the glTF file object
  82996. */
  82997. constructor();
  82998. /**
  82999. * Downloads the glTF data as files based on their names and data
  83000. */
  83001. downloadFiles(): void;
  83002. }
  83003. }
  83004. declare module BABYLON {
  83005. /**
  83006. * Holds a collection of exporter options and parameters
  83007. */
  83008. export interface IExportOptions {
  83009. /**
  83010. * Function which indicates whether a babylon node should be exported or not
  83011. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83012. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83013. */
  83014. shouldExportNode?(node: Node): boolean;
  83015. /**
  83016. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83017. * @param metadata source metadata to read from
  83018. * @returns the data to store to glTF node extras
  83019. */
  83020. metadataSelector?(metadata: any): any;
  83021. /**
  83022. * The sample rate to bake animation curves
  83023. */
  83024. animationSampleRate?: number;
  83025. /**
  83026. * Begin serialization without waiting for the scene to be ready
  83027. */
  83028. exportWithoutWaitingForScene?: boolean;
  83029. /**
  83030. * Indicates if coordinate system swapping root nodes should be included in export
  83031. */
  83032. includeCoordinateSystemConversionNodes?: boolean;
  83033. }
  83034. /**
  83035. * Class for generating glTF data from a Babylon scene.
  83036. */
  83037. export class GLTF2Export {
  83038. /**
  83039. * Exports the geometry of the scene to .gltf file format asynchronously
  83040. * @param scene Babylon scene with scene hierarchy information
  83041. * @param filePrefix File prefix to use when generating the glTF file
  83042. * @param options Exporter options
  83043. * @returns Returns an object with a .gltf file and associates texture names
  83044. * as keys and their data and paths as values
  83045. */
  83046. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83047. private static _PreExportAsync;
  83048. private static _PostExportAsync;
  83049. /**
  83050. * Exports the geometry of the scene to .glb file format asychronously
  83051. * @param scene Babylon scene with scene hierarchy information
  83052. * @param filePrefix File prefix to use when generating glb file
  83053. * @param options Exporter options
  83054. * @returns Returns an object with a .glb filename as key and data as value
  83055. */
  83056. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83057. }
  83058. }
  83059. declare module BABYLON.GLTF2.Exporter {
  83060. /**
  83061. * @hidden
  83062. */
  83063. export class _GLTFUtilities {
  83064. /**
  83065. * Creates a buffer view based on the supplied arguments
  83066. * @param bufferIndex index value of the specified buffer
  83067. * @param byteOffset byte offset value
  83068. * @param byteLength byte length of the bufferView
  83069. * @param byteStride byte distance between conequential elements
  83070. * @param name name of the buffer view
  83071. * @returns bufferView for glTF
  83072. */
  83073. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83074. /**
  83075. * Creates an accessor based on the supplied arguments
  83076. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83077. * @param name The name of the accessor
  83078. * @param type The type of the accessor
  83079. * @param componentType The datatype of components in the attribute
  83080. * @param count The number of attributes referenced by this accessor
  83081. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83082. * @param min Minimum value of each component in this attribute
  83083. * @param max Maximum value of each component in this attribute
  83084. * @returns accessor for glTF
  83085. */
  83086. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83087. /**
  83088. * Calculates the minimum and maximum values of an array of position floats
  83089. * @param positions Positions array of a mesh
  83090. * @param vertexStart Starting vertex offset to calculate min and max values
  83091. * @param vertexCount Number of vertices to check for min and max values
  83092. * @returns min number array and max number array
  83093. */
  83094. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83095. min: number[];
  83096. max: number[];
  83097. };
  83098. /**
  83099. * Converts a new right-handed Vector3
  83100. * @param vector vector3 array
  83101. * @returns right-handed Vector3
  83102. */
  83103. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83104. /**
  83105. * Converts a Vector3 to right-handed
  83106. * @param vector Vector3 to convert to right-handed
  83107. */
  83108. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83109. /**
  83110. * Converts a three element number array to right-handed
  83111. * @param vector number array to convert to right-handed
  83112. */
  83113. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83114. /**
  83115. * Converts a new right-handed Vector3
  83116. * @param vector vector3 array
  83117. * @returns right-handed Vector3
  83118. */
  83119. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83120. /**
  83121. * Converts a Vector3 to right-handed
  83122. * @param vector Vector3 to convert to right-handed
  83123. */
  83124. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83125. /**
  83126. * Converts a three element number array to right-handed
  83127. * @param vector number array to convert to right-handed
  83128. */
  83129. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83130. /**
  83131. * Converts a Vector4 to right-handed
  83132. * @param vector Vector4 to convert to right-handed
  83133. */
  83134. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83135. /**
  83136. * Converts a Vector4 to right-handed
  83137. * @param vector Vector4 to convert to right-handed
  83138. */
  83139. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83140. /**
  83141. * Converts a Quaternion to right-handed
  83142. * @param quaternion Source quaternion to convert to right-handed
  83143. */
  83144. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83145. /**
  83146. * Converts a Quaternion to right-handed
  83147. * @param quaternion Source quaternion to convert to right-handed
  83148. */
  83149. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83150. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83151. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83152. }
  83153. }
  83154. declare module BABYLON.GLTF2.Exporter {
  83155. /**
  83156. * Converts Babylon Scene into glTF 2.0.
  83157. * @hidden
  83158. */
  83159. export class _Exporter {
  83160. /**
  83161. * Stores the glTF to export
  83162. */
  83163. _glTF: IGLTF;
  83164. /**
  83165. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83166. */
  83167. _bufferViews: IBufferView[];
  83168. /**
  83169. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83170. */
  83171. _accessors: IAccessor[];
  83172. /**
  83173. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83174. */
  83175. _nodes: INode[];
  83176. /**
  83177. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83178. */
  83179. private _scenes;
  83180. /**
  83181. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83182. */
  83183. private _meshes;
  83184. /**
  83185. * Stores all the generated material information, which represents the appearance of each primitive
  83186. */
  83187. _materials: IMaterial[];
  83188. _materialMap: {
  83189. [materialID: number]: number;
  83190. };
  83191. /**
  83192. * Stores all the generated texture information, which is referenced by glTF materials
  83193. */
  83194. _textures: ITexture[];
  83195. /**
  83196. * Stores all the generated image information, which is referenced by glTF textures
  83197. */
  83198. _images: IImage[];
  83199. /**
  83200. * Stores all the texture samplers
  83201. */
  83202. _samplers: ISampler[];
  83203. /**
  83204. * Stores all the generated glTF skins
  83205. */
  83206. _skins: ISkin[];
  83207. /**
  83208. * Stores all the generated animation samplers, which is referenced by glTF animations
  83209. */
  83210. /**
  83211. * Stores the animations for glTF models
  83212. */
  83213. private _animations;
  83214. /**
  83215. * Stores the total amount of bytes stored in the glTF buffer
  83216. */
  83217. private _totalByteLength;
  83218. /**
  83219. * Stores a reference to the Babylon scene containing the source geometry and material information
  83220. */
  83221. _babylonScene: Scene;
  83222. /**
  83223. * Stores a map of the image data, where the key is the file name and the value
  83224. * is the image data
  83225. */
  83226. _imageData: {
  83227. [fileName: string]: {
  83228. data: Uint8Array;
  83229. mimeType: ImageMimeType;
  83230. };
  83231. };
  83232. /**
  83233. * Stores a map of the unique id of a node to its index in the node array
  83234. */
  83235. _nodeMap: {
  83236. [key: number]: number;
  83237. };
  83238. /**
  83239. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83240. */
  83241. _convertToRightHandedSystem: boolean;
  83242. /**
  83243. * Specifies if a Babylon node should be converted to right-handed on export
  83244. */
  83245. _convertToRightHandedSystemMap: {
  83246. [nodeId: number]: boolean;
  83247. };
  83248. _includeCoordinateSystemConversionNodes: boolean;
  83249. /**
  83250. * Baked animation sample rate
  83251. */
  83252. private _animationSampleRate;
  83253. private _options;
  83254. private _localEngine;
  83255. _glTFMaterialExporter: _GLTFMaterialExporter;
  83256. private _extensions;
  83257. private static _ExtensionNames;
  83258. private static _ExtensionFactories;
  83259. private _applyExtension;
  83260. private _applyExtensions;
  83261. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83262. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83263. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83264. [key: number]: number;
  83265. }): Promise<Nullable<INode>>;
  83266. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83267. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83268. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83269. private _forEachExtensions;
  83270. private _extensionsOnExporting;
  83271. /**
  83272. * Load glTF serializer extensions
  83273. */
  83274. private _loadExtensions;
  83275. /**
  83276. * Creates a glTF Exporter instance, which can accept optional exporter options
  83277. * @param babylonScene Babylon scene object
  83278. * @param options Options to modify the behavior of the exporter
  83279. */
  83280. constructor(babylonScene: Scene, options?: IExportOptions);
  83281. dispose(): void;
  83282. /**
  83283. * Registers a glTF exporter extension
  83284. * @param name Name of the extension to export
  83285. * @param factory The factory function that creates the exporter extension
  83286. */
  83287. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83288. /**
  83289. * Un-registers an exporter extension
  83290. * @param name The name fo the exporter extension
  83291. * @returns A boolean indicating whether the extension has been un-registered
  83292. */
  83293. static UnregisterExtension(name: string): boolean;
  83294. /**
  83295. * Lazy load a local engine
  83296. */
  83297. _getLocalEngine(): Engine;
  83298. private reorderIndicesBasedOnPrimitiveMode;
  83299. /**
  83300. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83301. * clock-wise during export to glTF
  83302. * @param submesh BabylonJS submesh
  83303. * @param primitiveMode Primitive mode of the mesh
  83304. * @param sideOrientation the winding order of the submesh
  83305. * @param vertexBufferKind The type of vertex attribute
  83306. * @param meshAttributeArray The vertex attribute data
  83307. * @param byteOffset The offset to the binary data
  83308. * @param binaryWriter The binary data for the glTF file
  83309. * @param convertToRightHandedSystem Converts the values to right-handed
  83310. */
  83311. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83312. /**
  83313. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83314. * clock-wise during export to glTF
  83315. * @param submesh BabylonJS submesh
  83316. * @param primitiveMode Primitive mode of the mesh
  83317. * @param sideOrientation the winding order of the submesh
  83318. * @param vertexBufferKind The type of vertex attribute
  83319. * @param meshAttributeArray The vertex attribute data
  83320. * @param byteOffset The offset to the binary data
  83321. * @param binaryWriter The binary data for the glTF file
  83322. * @param convertToRightHandedSystem Converts the values to right-handed
  83323. */
  83324. private reorderTriangleFillMode;
  83325. /**
  83326. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83327. * clock-wise during export to glTF
  83328. * @param submesh BabylonJS submesh
  83329. * @param primitiveMode Primitive mode of the mesh
  83330. * @param sideOrientation the winding order of the submesh
  83331. * @param vertexBufferKind The type of vertex attribute
  83332. * @param meshAttributeArray The vertex attribute data
  83333. * @param byteOffset The offset to the binary data
  83334. * @param binaryWriter The binary data for the glTF file
  83335. * @param convertToRightHandedSystem Converts the values to right-handed
  83336. */
  83337. private reorderTriangleStripDrawMode;
  83338. /**
  83339. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83340. * clock-wise during export to glTF
  83341. * @param submesh BabylonJS submesh
  83342. * @param primitiveMode Primitive mode of the mesh
  83343. * @param sideOrientation the winding order of the submesh
  83344. * @param vertexBufferKind The type of vertex attribute
  83345. * @param meshAttributeArray The vertex attribute data
  83346. * @param byteOffset The offset to the binary data
  83347. * @param binaryWriter The binary data for the glTF file
  83348. * @param convertToRightHandedSystem Converts the values to right-handed
  83349. */
  83350. private reorderTriangleFanMode;
  83351. /**
  83352. * Writes the vertex attribute data to binary
  83353. * @param vertices The vertices to write to the binary writer
  83354. * @param byteOffset The offset into the binary writer to overwrite binary data
  83355. * @param vertexAttributeKind The vertex attribute type
  83356. * @param meshAttributeArray The vertex attribute data
  83357. * @param binaryWriter The writer containing the binary data
  83358. * @param convertToRightHandedSystem Converts the values to right-handed
  83359. */
  83360. private writeVertexAttributeData;
  83361. /**
  83362. * Writes mesh attribute data to a data buffer
  83363. * Returns the bytelength of the data
  83364. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83365. * @param meshAttributeArray Array containing the attribute data
  83366. * @param byteStride Specifies the space between data
  83367. * @param binaryWriter The buffer to write the binary data to
  83368. * @param convertToRightHandedSystem Converts the values to right-handed
  83369. */
  83370. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83371. /**
  83372. * Generates glTF json data
  83373. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83374. * @param glTFPrefix Text to use when prefixing a glTF file
  83375. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83376. * @returns json data as string
  83377. */
  83378. private generateJSON;
  83379. /**
  83380. * Generates data for .gltf and .bin files based on the glTF prefix string
  83381. * @param glTFPrefix Text to use when prefixing a glTF file
  83382. * @param dispose Dispose the exporter
  83383. * @returns GLTFData with glTF file data
  83384. */
  83385. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83386. /**
  83387. * Creates a binary buffer for glTF
  83388. * @returns array buffer for binary data
  83389. */
  83390. private _generateBinaryAsync;
  83391. /**
  83392. * Pads the number to a multiple of 4
  83393. * @param num number to pad
  83394. * @returns padded number
  83395. */
  83396. private _getPadding;
  83397. /**
  83398. * @hidden
  83399. */
  83400. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83401. /**
  83402. * Sets the TRS for each node
  83403. * @param node glTF Node for storing the transformation data
  83404. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83405. * @param convertToRightHandedSystem Converts the values to right-handed
  83406. */
  83407. private setNodeTransformation;
  83408. private getVertexBufferFromMesh;
  83409. /**
  83410. * Creates a bufferview based on the vertices type for the Babylon mesh
  83411. * @param kind Indicates the type of vertices data
  83412. * @param componentType Indicates the numerical type used to store the data
  83413. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83414. * @param binaryWriter The buffer to write the bufferview data to
  83415. * @param convertToRightHandedSystem Converts the values to right-handed
  83416. */
  83417. private createBufferViewKind;
  83418. /**
  83419. * The primitive mode of the Babylon mesh
  83420. * @param babylonMesh The BabylonJS mesh
  83421. */
  83422. private getMeshPrimitiveMode;
  83423. /**
  83424. * Sets the primitive mode of the glTF mesh primitive
  83425. * @param meshPrimitive glTF mesh primitive
  83426. * @param primitiveMode The primitive mode
  83427. */
  83428. private setPrimitiveMode;
  83429. /**
  83430. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83431. * @param meshPrimitive glTF mesh primitive
  83432. * @param attributeKind vertex attribute
  83433. * @returns boolean specifying if uv coordinates are present
  83434. */
  83435. private setAttributeKind;
  83436. /**
  83437. * Sets data for the primitive attributes of each submesh
  83438. * @param mesh glTF Mesh object to store the primitive attribute information
  83439. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83440. * @param binaryWriter Buffer to write the attribute data to
  83441. * @param convertToRightHandedSystem Converts the values to right-handed
  83442. */
  83443. private setPrimitiveAttributesAsync;
  83444. /**
  83445. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83446. * @param node The node to check
  83447. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83448. */
  83449. private isBabylonCoordinateSystemConvertingNode;
  83450. /**
  83451. * Creates a glTF scene based on the array of meshes
  83452. * Returns the the total byte offset
  83453. * @param babylonScene Babylon scene to get the mesh data from
  83454. * @param binaryWriter Buffer to write binary data to
  83455. */
  83456. private createSceneAsync;
  83457. /**
  83458. * Creates a mapping of Node unique id to node index and handles animations
  83459. * @param babylonScene Babylon Scene
  83460. * @param nodes Babylon transform nodes
  83461. * @param binaryWriter Buffer to write binary data to
  83462. * @returns Node mapping of unique id to index
  83463. */
  83464. private createNodeMapAndAnimationsAsync;
  83465. /**
  83466. * Creates a glTF node from a Babylon mesh
  83467. * @param babylonMesh Source Babylon mesh
  83468. * @param binaryWriter Buffer for storing geometry data
  83469. * @param convertToRightHandedSystem Converts the values to right-handed
  83470. * @param nodeMap Node mapping of unique id to glTF node index
  83471. * @returns glTF node
  83472. */
  83473. private createNodeAsync;
  83474. /**
  83475. * Creates a glTF skin from a Babylon skeleton
  83476. * @param babylonScene Babylon Scene
  83477. * @param nodes Babylon transform nodes
  83478. * @param binaryWriter Buffer to write binary data to
  83479. * @returns Node mapping of unique id to index
  83480. */
  83481. private createSkinsAsync;
  83482. }
  83483. /**
  83484. * @hidden
  83485. *
  83486. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83487. */
  83488. export class _BinaryWriter {
  83489. /**
  83490. * Array buffer which stores all binary data
  83491. */
  83492. private _arrayBuffer;
  83493. /**
  83494. * View of the array buffer
  83495. */
  83496. private _dataView;
  83497. /**
  83498. * byte offset of data in array buffer
  83499. */
  83500. private _byteOffset;
  83501. /**
  83502. * Initialize binary writer with an initial byte length
  83503. * @param byteLength Initial byte length of the array buffer
  83504. */
  83505. constructor(byteLength: number);
  83506. /**
  83507. * Resize the array buffer to the specified byte length
  83508. * @param byteLength
  83509. */
  83510. private resizeBuffer;
  83511. /**
  83512. * Get an array buffer with the length of the byte offset
  83513. * @returns ArrayBuffer resized to the byte offset
  83514. */
  83515. getArrayBuffer(): ArrayBuffer;
  83516. /**
  83517. * Get the byte offset of the array buffer
  83518. * @returns byte offset
  83519. */
  83520. getByteOffset(): number;
  83521. /**
  83522. * Stores an UInt8 in the array buffer
  83523. * @param entry
  83524. * @param byteOffset If defined, specifies where to set the value as an offset.
  83525. */
  83526. setUInt8(entry: number, byteOffset?: number): void;
  83527. /**
  83528. * Stores an UInt16 in the array buffer
  83529. * @param entry
  83530. * @param byteOffset If defined, specifies where to set the value as an offset.
  83531. */
  83532. setUInt16(entry: number, byteOffset?: number): void;
  83533. /**
  83534. * Gets an UInt32 in the array buffer
  83535. * @param entry
  83536. * @param byteOffset If defined, specifies where to set the value as an offset.
  83537. */
  83538. getUInt32(byteOffset: number): number;
  83539. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83540. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83541. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83542. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83543. /**
  83544. * Stores a Float32 in the array buffer
  83545. * @param entry
  83546. */
  83547. setFloat32(entry: number, byteOffset?: number): void;
  83548. /**
  83549. * Stores an UInt32 in the array buffer
  83550. * @param entry
  83551. * @param byteOffset If defined, specifies where to set the value as an offset.
  83552. */
  83553. setUInt32(entry: number, byteOffset?: number): void;
  83554. }
  83555. }
  83556. declare module BABYLON.GLTF2.Exporter {
  83557. /**
  83558. * @hidden
  83559. * Interface to store animation data.
  83560. */
  83561. export interface _IAnimationData {
  83562. /**
  83563. * Keyframe data.
  83564. */
  83565. inputs: number[];
  83566. /**
  83567. * Value data.
  83568. */
  83569. outputs: number[][];
  83570. /**
  83571. * Animation interpolation data.
  83572. */
  83573. samplerInterpolation: AnimationSamplerInterpolation;
  83574. /**
  83575. * Minimum keyframe value.
  83576. */
  83577. inputsMin: number;
  83578. /**
  83579. * Maximum keyframe value.
  83580. */
  83581. inputsMax: number;
  83582. }
  83583. /**
  83584. * @hidden
  83585. */
  83586. export interface _IAnimationInfo {
  83587. /**
  83588. * The target channel for the animation
  83589. */
  83590. animationChannelTargetPath: AnimationChannelTargetPath;
  83591. /**
  83592. * The glTF accessor type for the data.
  83593. */
  83594. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  83595. /**
  83596. * Specifies if quaternions should be used.
  83597. */
  83598. useQuaternion: boolean;
  83599. }
  83600. /**
  83601. * @hidden
  83602. * Utility class for generating glTF animation data from BabylonJS.
  83603. */
  83604. export class _GLTFAnimation {
  83605. /**
  83606. * @ignore
  83607. *
  83608. * Creates glTF channel animation from BabylonJS animation.
  83609. * @param babylonTransformNode - BabylonJS mesh.
  83610. * @param animation - animation.
  83611. * @param animationChannelTargetPath - The target animation channel.
  83612. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83613. * @param useQuaternion - Specifies if quaternions are used.
  83614. * @returns nullable IAnimationData
  83615. */
  83616. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83617. private static _DeduceAnimationInfo;
  83618. /**
  83619. * @ignore
  83620. * Create node animations from the transform node animations
  83621. * @param babylonNode
  83622. * @param runtimeGLTFAnimation
  83623. * @param idleGLTFAnimations
  83624. * @param nodeMap
  83625. * @param nodes
  83626. * @param binaryWriter
  83627. * @param bufferViews
  83628. * @param accessors
  83629. * @param convertToRightHandedSystem
  83630. * @param animationSampleRate
  83631. */
  83632. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83633. [key: number]: number;
  83634. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83635. /**
  83636. * @ignore
  83637. * Create node animations from the animation groups
  83638. * @param babylonScene
  83639. * @param glTFAnimations
  83640. * @param nodeMap
  83641. * @param nodes
  83642. * @param binaryWriter
  83643. * @param bufferViews
  83644. * @param accessors
  83645. * @param convertToRightHandedSystemMap
  83646. * @param animationSampleRate
  83647. */
  83648. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83649. [key: number]: number;
  83650. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83651. [nodeId: number]: boolean;
  83652. }, animationSampleRate: number): void;
  83653. private static AddAnimation;
  83654. /**
  83655. * Create a baked animation
  83656. * @param babylonTransformNode BabylonJS mesh
  83657. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83658. * @param animationChannelTargetPath animation target channel
  83659. * @param minFrame minimum animation frame
  83660. * @param maxFrame maximum animation frame
  83661. * @param fps frames per second of the animation
  83662. * @param inputs input key frames of the animation
  83663. * @param outputs output key frame data of the animation
  83664. * @param convertToRightHandedSystem converts the values to right-handed
  83665. * @param useQuaternion specifies if quaternions should be used
  83666. */
  83667. private static _CreateBakedAnimation;
  83668. private static _ConvertFactorToVector3OrQuaternion;
  83669. private static _SetInterpolatedValue;
  83670. /**
  83671. * Creates linear animation from the animation key frames
  83672. * @param babylonTransformNode BabylonJS mesh
  83673. * @param animation BabylonJS animation
  83674. * @param animationChannelTargetPath The target animation channel
  83675. * @param frameDelta The difference between the last and first frame of the animation
  83676. * @param inputs Array to store the key frame times
  83677. * @param outputs Array to store the key frame data
  83678. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83679. * @param useQuaternion Specifies if quaternions are used in the animation
  83680. */
  83681. private static _CreateLinearOrStepAnimation;
  83682. /**
  83683. * Creates cubic spline animation from the animation key frames
  83684. * @param babylonTransformNode BabylonJS mesh
  83685. * @param animation BabylonJS animation
  83686. * @param animationChannelTargetPath The target animation channel
  83687. * @param frameDelta The difference between the last and first frame of the animation
  83688. * @param inputs Array to store the key frame times
  83689. * @param outputs Array to store the key frame data
  83690. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83691. * @param useQuaternion Specifies if quaternions are used in the animation
  83692. */
  83693. private static _CreateCubicSplineAnimation;
  83694. private static _GetBasePositionRotationOrScale;
  83695. /**
  83696. * Adds a key frame value
  83697. * @param keyFrame
  83698. * @param animation
  83699. * @param outputs
  83700. * @param animationChannelTargetPath
  83701. * @param basePositionRotationOrScale
  83702. * @param convertToRightHandedSystem
  83703. * @param useQuaternion
  83704. */
  83705. private static _AddKeyframeValue;
  83706. /**
  83707. * Determine the interpolation based on the key frames
  83708. * @param keyFrames
  83709. * @param animationChannelTargetPath
  83710. * @param useQuaternion
  83711. */
  83712. private static _DeduceInterpolation;
  83713. /**
  83714. * Adds an input tangent or output tangent to the output data
  83715. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83716. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83717. * @param outputs The animation data by keyframe
  83718. * @param animationChannelTargetPath The target animation channel
  83719. * @param interpolation The interpolation type
  83720. * @param keyFrame The key frame with the animation data
  83721. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83722. * @param useQuaternion Specifies if quaternions are used
  83723. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83724. */
  83725. private static AddSplineTangent;
  83726. /**
  83727. * Get the minimum and maximum key frames' frame values
  83728. * @param keyFrames animation key frames
  83729. * @returns the minimum and maximum key frame value
  83730. */
  83731. private static calculateMinMaxKeyFrames;
  83732. }
  83733. }
  83734. declare module BABYLON.GLTF2.Exporter {
  83735. /** @hidden */
  83736. export var textureTransformPixelShader: {
  83737. name: string;
  83738. shader: string;
  83739. };
  83740. }
  83741. declare module BABYLON.GLTF2.Exporter.Extensions {
  83742. /**
  83743. * @hidden
  83744. */
  83745. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83746. private _recordedTextures;
  83747. /** Name of this extension */
  83748. readonly name: string;
  83749. /** Defines whether this extension is enabled */
  83750. enabled: boolean;
  83751. /** Defines whether this extension is required */
  83752. required: boolean;
  83753. /** Reference to the glTF exporter */
  83754. private _wasUsed;
  83755. constructor(exporter: _Exporter);
  83756. dispose(): void;
  83757. /** @hidden */
  83758. get wasUsed(): boolean;
  83759. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83760. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83761. /**
  83762. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83763. * @param babylonTexture
  83764. * @param offset
  83765. * @param rotation
  83766. * @param scale
  83767. * @param scene
  83768. */
  83769. private _textureTransformTextureAsync;
  83770. }
  83771. }
  83772. declare module BABYLON.GLTF2.Exporter.Extensions {
  83773. /**
  83774. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83775. */
  83776. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83777. /** The name of this extension. */
  83778. readonly name: string;
  83779. /** Defines whether this extension is enabled. */
  83780. enabled: boolean;
  83781. /** Defines whether this extension is required */
  83782. required: boolean;
  83783. /** Reference to the glTF exporter */
  83784. private _exporter;
  83785. private _lights;
  83786. /** @hidden */
  83787. constructor(exporter: _Exporter);
  83788. /** @hidden */
  83789. dispose(): void;
  83790. /** @hidden */
  83791. get wasUsed(): boolean;
  83792. /** @hidden */
  83793. onExporting(): void;
  83794. /**
  83795. * Define this method to modify the default behavior when exporting a node
  83796. * @param context The context when exporting the node
  83797. * @param node glTF node
  83798. * @param babylonNode BabylonJS node
  83799. * @param nodeMap Node mapping of unique id to glTF node index
  83800. * @returns nullable INode promise
  83801. */
  83802. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83803. [key: number]: number;
  83804. }): Promise<Nullable<INode>>;
  83805. }
  83806. }
  83807. declare module BABYLON.GLTF2.Exporter.Extensions {
  83808. /**
  83809. * @hidden
  83810. */
  83811. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83812. /** Name of this extension */
  83813. readonly name: string;
  83814. /** Defines whether this extension is enabled */
  83815. enabled: boolean;
  83816. /** Defines whether this extension is required */
  83817. required: boolean;
  83818. /** Reference to the glTF exporter */
  83819. private _textureInfos;
  83820. private _exportedTextures;
  83821. private _wasUsed;
  83822. constructor(exporter: _Exporter);
  83823. dispose(): void;
  83824. /** @hidden */
  83825. get wasUsed(): boolean;
  83826. private _getTextureIndex;
  83827. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83828. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83829. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83830. }
  83831. }
  83832. declare module BABYLON.GLTF2.Exporter.Extensions {
  83833. /**
  83834. * @hidden
  83835. */
  83836. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83837. /** Name of this extension */
  83838. readonly name: string;
  83839. /** Defines whether this extension is enabled */
  83840. enabled: boolean;
  83841. /** Defines whether this extension is required */
  83842. required: boolean;
  83843. private _wasUsed;
  83844. constructor(exporter: _Exporter);
  83845. /** @hidden */
  83846. get wasUsed(): boolean;
  83847. dispose(): void;
  83848. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83849. }
  83850. }
  83851. declare module BABYLON {
  83852. /**
  83853. * Class for generating STL data from a Babylon scene.
  83854. */
  83855. export class STLExport {
  83856. /**
  83857. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83858. * @param meshes list defines the mesh to serialize
  83859. * @param download triggers the automatic download of the file.
  83860. * @param fileName changes the downloads fileName.
  83861. * @param binary changes the STL to a binary type.
  83862. * @param isLittleEndian toggle for binary type exporter.
  83863. * @returns the STL as UTF8 string
  83864. */
  83865. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83866. }
  83867. }
  83868. declare module "babylonjs-gltf2interface" {
  83869. export = BABYLON.GLTF2;
  83870. }
  83871. /**
  83872. * Module for glTF 2.0 Interface
  83873. */
  83874. declare module BABYLON.GLTF2 {
  83875. /**
  83876. * The datatype of the components in the attribute
  83877. */
  83878. const enum AccessorComponentType {
  83879. /**
  83880. * Byte
  83881. */
  83882. BYTE = 5120,
  83883. /**
  83884. * Unsigned Byte
  83885. */
  83886. UNSIGNED_BYTE = 5121,
  83887. /**
  83888. * Short
  83889. */
  83890. SHORT = 5122,
  83891. /**
  83892. * Unsigned Short
  83893. */
  83894. UNSIGNED_SHORT = 5123,
  83895. /**
  83896. * Unsigned Int
  83897. */
  83898. UNSIGNED_INT = 5125,
  83899. /**
  83900. * Float
  83901. */
  83902. FLOAT = 5126,
  83903. }
  83904. /**
  83905. * Specifies if the attirbute is a scalar, vector, or matrix
  83906. */
  83907. const enum AccessorType {
  83908. /**
  83909. * Scalar
  83910. */
  83911. SCALAR = "SCALAR",
  83912. /**
  83913. * Vector2
  83914. */
  83915. VEC2 = "VEC2",
  83916. /**
  83917. * Vector3
  83918. */
  83919. VEC3 = "VEC3",
  83920. /**
  83921. * Vector4
  83922. */
  83923. VEC4 = "VEC4",
  83924. /**
  83925. * Matrix2x2
  83926. */
  83927. MAT2 = "MAT2",
  83928. /**
  83929. * Matrix3x3
  83930. */
  83931. MAT3 = "MAT3",
  83932. /**
  83933. * Matrix4x4
  83934. */
  83935. MAT4 = "MAT4",
  83936. }
  83937. /**
  83938. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83939. */
  83940. const enum AnimationChannelTargetPath {
  83941. /**
  83942. * Translation
  83943. */
  83944. TRANSLATION = "translation",
  83945. /**
  83946. * Rotation
  83947. */
  83948. ROTATION = "rotation",
  83949. /**
  83950. * Scale
  83951. */
  83952. SCALE = "scale",
  83953. /**
  83954. * Weights
  83955. */
  83956. WEIGHTS = "weights",
  83957. }
  83958. /**
  83959. * Interpolation algorithm
  83960. */
  83961. const enum AnimationSamplerInterpolation {
  83962. /**
  83963. * The animated values are linearly interpolated between keyframes
  83964. */
  83965. LINEAR = "LINEAR",
  83966. /**
  83967. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83968. */
  83969. STEP = "STEP",
  83970. /**
  83971. * The animation's interpolation is computed using a cubic spline with specified tangents
  83972. */
  83973. CUBICSPLINE = "CUBICSPLINE",
  83974. }
  83975. /**
  83976. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83977. */
  83978. const enum CameraType {
  83979. /**
  83980. * A perspective camera containing properties to create a perspective projection matrix
  83981. */
  83982. PERSPECTIVE = "perspective",
  83983. /**
  83984. * An orthographic camera containing properties to create an orthographic projection matrix
  83985. */
  83986. ORTHOGRAPHIC = "orthographic",
  83987. }
  83988. /**
  83989. * The mime-type of the image
  83990. */
  83991. const enum ImageMimeType {
  83992. /**
  83993. * JPEG Mime-type
  83994. */
  83995. JPEG = "image/jpeg",
  83996. /**
  83997. * PNG Mime-type
  83998. */
  83999. PNG = "image/png",
  84000. }
  84001. /**
  84002. * The alpha rendering mode of the material
  84003. */
  84004. const enum MaterialAlphaMode {
  84005. /**
  84006. * The alpha value is ignored and the rendered output is fully opaque
  84007. */
  84008. OPAQUE = "OPAQUE",
  84009. /**
  84010. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84011. */
  84012. MASK = "MASK",
  84013. /**
  84014. * 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)
  84015. */
  84016. BLEND = "BLEND",
  84017. }
  84018. /**
  84019. * The type of the primitives to render
  84020. */
  84021. const enum MeshPrimitiveMode {
  84022. /**
  84023. * Points
  84024. */
  84025. POINTS = 0,
  84026. /**
  84027. * Lines
  84028. */
  84029. LINES = 1,
  84030. /**
  84031. * Line Loop
  84032. */
  84033. LINE_LOOP = 2,
  84034. /**
  84035. * Line Strip
  84036. */
  84037. LINE_STRIP = 3,
  84038. /**
  84039. * Triangles
  84040. */
  84041. TRIANGLES = 4,
  84042. /**
  84043. * Triangle Strip
  84044. */
  84045. TRIANGLE_STRIP = 5,
  84046. /**
  84047. * Triangle Fan
  84048. */
  84049. TRIANGLE_FAN = 6,
  84050. }
  84051. /**
  84052. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84053. */
  84054. const enum TextureMagFilter {
  84055. /**
  84056. * Nearest
  84057. */
  84058. NEAREST = 9728,
  84059. /**
  84060. * Linear
  84061. */
  84062. LINEAR = 9729,
  84063. }
  84064. /**
  84065. * Minification filter. All valid values correspond to WebGL enums
  84066. */
  84067. const enum TextureMinFilter {
  84068. /**
  84069. * Nearest
  84070. */
  84071. NEAREST = 9728,
  84072. /**
  84073. * Linear
  84074. */
  84075. LINEAR = 9729,
  84076. /**
  84077. * Nearest Mip-Map Nearest
  84078. */
  84079. NEAREST_MIPMAP_NEAREST = 9984,
  84080. /**
  84081. * Linear Mipmap Nearest
  84082. */
  84083. LINEAR_MIPMAP_NEAREST = 9985,
  84084. /**
  84085. * Nearest Mipmap Linear
  84086. */
  84087. NEAREST_MIPMAP_LINEAR = 9986,
  84088. /**
  84089. * Linear Mipmap Linear
  84090. */
  84091. LINEAR_MIPMAP_LINEAR = 9987,
  84092. }
  84093. /**
  84094. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84095. */
  84096. const enum TextureWrapMode {
  84097. /**
  84098. * Clamp to Edge
  84099. */
  84100. CLAMP_TO_EDGE = 33071,
  84101. /**
  84102. * Mirrored Repeat
  84103. */
  84104. MIRRORED_REPEAT = 33648,
  84105. /**
  84106. * Repeat
  84107. */
  84108. REPEAT = 10497,
  84109. }
  84110. /**
  84111. * glTF Property
  84112. */
  84113. interface IProperty {
  84114. /**
  84115. * Dictionary object with extension-specific objects
  84116. */
  84117. extensions?: {
  84118. [key: string]: any;
  84119. };
  84120. /**
  84121. * Application-Specific data
  84122. */
  84123. extras?: any;
  84124. }
  84125. /**
  84126. * glTF Child of Root Property
  84127. */
  84128. interface IChildRootProperty extends IProperty {
  84129. /**
  84130. * The user-defined name of this object
  84131. */
  84132. name?: string;
  84133. }
  84134. /**
  84135. * Indices of those attributes that deviate from their initialization value
  84136. */
  84137. interface IAccessorSparseIndices extends IProperty {
  84138. /**
  84139. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84140. */
  84141. bufferView: number;
  84142. /**
  84143. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84144. */
  84145. byteOffset?: number;
  84146. /**
  84147. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84148. */
  84149. componentType: AccessorComponentType;
  84150. }
  84151. /**
  84152. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84153. */
  84154. interface IAccessorSparseValues extends IProperty {
  84155. /**
  84156. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84157. */
  84158. bufferView: number;
  84159. /**
  84160. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84161. */
  84162. byteOffset?: number;
  84163. }
  84164. /**
  84165. * Sparse storage of attributes that deviate from their initialization value
  84166. */
  84167. interface IAccessorSparse extends IProperty {
  84168. /**
  84169. * The number of attributes encoded in this sparse accessor
  84170. */
  84171. count: number;
  84172. /**
  84173. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84174. */
  84175. indices: IAccessorSparseIndices;
  84176. /**
  84177. * 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
  84178. */
  84179. values: IAccessorSparseValues;
  84180. }
  84181. /**
  84182. * 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
  84183. */
  84184. interface IAccessor extends IChildRootProperty {
  84185. /**
  84186. * The index of the bufferview
  84187. */
  84188. bufferView?: number;
  84189. /**
  84190. * The offset relative to the start of the bufferView in bytes
  84191. */
  84192. byteOffset?: number;
  84193. /**
  84194. * The datatype of components in the attribute
  84195. */
  84196. componentType: AccessorComponentType;
  84197. /**
  84198. * Specifies whether integer data values should be normalized
  84199. */
  84200. normalized?: boolean;
  84201. /**
  84202. * The number of attributes referenced by this accessor
  84203. */
  84204. count: number;
  84205. /**
  84206. * Specifies if the attribute is a scalar, vector, or matrix
  84207. */
  84208. type: AccessorType;
  84209. /**
  84210. * Maximum value of each component in this attribute
  84211. */
  84212. max?: number[];
  84213. /**
  84214. * Minimum value of each component in this attribute
  84215. */
  84216. min?: number[];
  84217. /**
  84218. * Sparse storage of attributes that deviate from their initialization value
  84219. */
  84220. sparse?: IAccessorSparse;
  84221. }
  84222. /**
  84223. * Targets an animation's sampler at a node's property
  84224. */
  84225. interface IAnimationChannel extends IProperty {
  84226. /**
  84227. * The index of a sampler in this animation used to compute the value for the target
  84228. */
  84229. sampler: number;
  84230. /**
  84231. * The index of the node and TRS property to target
  84232. */
  84233. target: IAnimationChannelTarget;
  84234. }
  84235. /**
  84236. * The index of the node and TRS property that an animation channel targets
  84237. */
  84238. interface IAnimationChannelTarget extends IProperty {
  84239. /**
  84240. * The index of the node to target
  84241. */
  84242. node: number;
  84243. /**
  84244. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84245. */
  84246. path: AnimationChannelTargetPath;
  84247. }
  84248. /**
  84249. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84250. */
  84251. interface IAnimationSampler extends IProperty {
  84252. /**
  84253. * The index of an accessor containing keyframe input values, e.g., time
  84254. */
  84255. input: number;
  84256. /**
  84257. * Interpolation algorithm
  84258. */
  84259. interpolation?: AnimationSamplerInterpolation;
  84260. /**
  84261. * The index of an accessor, containing keyframe output values
  84262. */
  84263. output: number;
  84264. }
  84265. /**
  84266. * A keyframe animation
  84267. */
  84268. interface IAnimation extends IChildRootProperty {
  84269. /**
  84270. * An array of channels, each of which targets an animation's sampler at a node's property
  84271. */
  84272. channels: IAnimationChannel[];
  84273. /**
  84274. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84275. */
  84276. samplers: IAnimationSampler[];
  84277. }
  84278. /**
  84279. * Metadata about the glTF asset
  84280. */
  84281. interface IAsset extends IChildRootProperty {
  84282. /**
  84283. * A copyright message suitable for display to credit the content creator
  84284. */
  84285. copyright?: string;
  84286. /**
  84287. * Tool that generated this glTF model. Useful for debugging
  84288. */
  84289. generator?: string;
  84290. /**
  84291. * The glTF version that this asset targets
  84292. */
  84293. version: string;
  84294. /**
  84295. * The minimum glTF version that this asset targets
  84296. */
  84297. minVersion?: string;
  84298. }
  84299. /**
  84300. * A buffer points to binary geometry, animation, or skins
  84301. */
  84302. interface IBuffer extends IChildRootProperty {
  84303. /**
  84304. * 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
  84305. */
  84306. uri?: string;
  84307. /**
  84308. * The length of the buffer in bytes
  84309. */
  84310. byteLength: number;
  84311. }
  84312. /**
  84313. * A view into a buffer generally representing a subset of the buffer
  84314. */
  84315. interface IBufferView extends IChildRootProperty {
  84316. /**
  84317. * The index of the buffer
  84318. */
  84319. buffer: number;
  84320. /**
  84321. * The offset into the buffer in bytes
  84322. */
  84323. byteOffset?: number;
  84324. /**
  84325. * The lenth of the bufferView in bytes
  84326. */
  84327. byteLength: number;
  84328. /**
  84329. * The stride, in bytes
  84330. */
  84331. byteStride?: number;
  84332. }
  84333. /**
  84334. * An orthographic camera containing properties to create an orthographic projection matrix
  84335. */
  84336. interface ICameraOrthographic extends IProperty {
  84337. /**
  84338. * The floating-point horizontal magnification of the view. Must not be zero
  84339. */
  84340. xmag: number;
  84341. /**
  84342. * The floating-point vertical magnification of the view. Must not be zero
  84343. */
  84344. ymag: number;
  84345. /**
  84346. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84347. */
  84348. zfar: number;
  84349. /**
  84350. * The floating-point distance to the near clipping plane
  84351. */
  84352. znear: number;
  84353. }
  84354. /**
  84355. * A perspective camera containing properties to create a perspective projection matrix
  84356. */
  84357. interface ICameraPerspective extends IProperty {
  84358. /**
  84359. * The floating-point aspect ratio of the field of view
  84360. */
  84361. aspectRatio?: number;
  84362. /**
  84363. * The floating-point vertical field of view in radians
  84364. */
  84365. yfov: number;
  84366. /**
  84367. * The floating-point distance to the far clipping plane
  84368. */
  84369. zfar?: number;
  84370. /**
  84371. * The floating-point distance to the near clipping plane
  84372. */
  84373. znear: number;
  84374. }
  84375. /**
  84376. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84377. */
  84378. interface ICamera extends IChildRootProperty {
  84379. /**
  84380. * An orthographic camera containing properties to create an orthographic projection matrix
  84381. */
  84382. orthographic?: ICameraOrthographic;
  84383. /**
  84384. * A perspective camera containing properties to create a perspective projection matrix
  84385. */
  84386. perspective?: ICameraPerspective;
  84387. /**
  84388. * Specifies if the camera uses a perspective or orthographic projection
  84389. */
  84390. type: CameraType;
  84391. }
  84392. /**
  84393. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84394. */
  84395. interface IImage extends IChildRootProperty {
  84396. /**
  84397. * 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
  84398. */
  84399. uri?: string;
  84400. /**
  84401. * The image's MIME type
  84402. */
  84403. mimeType?: ImageMimeType;
  84404. /**
  84405. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84406. */
  84407. bufferView?: number;
  84408. }
  84409. /**
  84410. * Material Normal Texture Info
  84411. */
  84412. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84413. /**
  84414. * The scalar multiplier applied to each normal vector of the normal texture
  84415. */
  84416. scale?: number;
  84417. }
  84418. /**
  84419. * Material Occlusion Texture Info
  84420. */
  84421. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84422. /**
  84423. * A scalar multiplier controlling the amount of occlusion applied
  84424. */
  84425. strength?: number;
  84426. }
  84427. /**
  84428. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84429. */
  84430. interface IMaterialPbrMetallicRoughness {
  84431. /**
  84432. * The material's base color factor
  84433. */
  84434. baseColorFactor?: number[];
  84435. /**
  84436. * The base color texture
  84437. */
  84438. baseColorTexture?: ITextureInfo;
  84439. /**
  84440. * The metalness of the material
  84441. */
  84442. metallicFactor?: number;
  84443. /**
  84444. * The roughness of the material
  84445. */
  84446. roughnessFactor?: number;
  84447. /**
  84448. * The metallic-roughness texture
  84449. */
  84450. metallicRoughnessTexture?: ITextureInfo;
  84451. }
  84452. /**
  84453. * The material appearance of a primitive
  84454. */
  84455. interface IMaterial extends IChildRootProperty {
  84456. /**
  84457. * 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
  84458. */
  84459. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84460. /**
  84461. * The normal map texture
  84462. */
  84463. normalTexture?: IMaterialNormalTextureInfo;
  84464. /**
  84465. * The occlusion map texture
  84466. */
  84467. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84468. /**
  84469. * The emissive map texture
  84470. */
  84471. emissiveTexture?: ITextureInfo;
  84472. /**
  84473. * 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
  84474. */
  84475. emissiveFactor?: number[];
  84476. /**
  84477. * The alpha rendering mode of the material
  84478. */
  84479. alphaMode?: MaterialAlphaMode;
  84480. /**
  84481. * The alpha cutoff value of the material
  84482. */
  84483. alphaCutoff?: number;
  84484. /**
  84485. * Specifies whether the material is double sided
  84486. */
  84487. doubleSided?: boolean;
  84488. }
  84489. /**
  84490. * Geometry to be rendered with the given material
  84491. */
  84492. interface IMeshPrimitive extends IProperty {
  84493. /**
  84494. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84495. */
  84496. attributes: {
  84497. [name: string]: number;
  84498. };
  84499. /**
  84500. * The index of the accessor that contains the indices
  84501. */
  84502. indices?: number;
  84503. /**
  84504. * The index of the material to apply to this primitive when rendering
  84505. */
  84506. material?: number;
  84507. /**
  84508. * The type of primitives to render. All valid values correspond to WebGL enums
  84509. */
  84510. mode?: MeshPrimitiveMode;
  84511. /**
  84512. * 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
  84513. */
  84514. targets?: {
  84515. [name: string]: number;
  84516. }[];
  84517. }
  84518. /**
  84519. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84520. */
  84521. interface IMesh extends IChildRootProperty {
  84522. /**
  84523. * An array of primitives, each defining geometry to be rendered with a material
  84524. */
  84525. primitives: IMeshPrimitive[];
  84526. /**
  84527. * Array of weights to be applied to the Morph Targets
  84528. */
  84529. weights?: number[];
  84530. }
  84531. /**
  84532. * A node in the node hierarchy
  84533. */
  84534. interface INode extends IChildRootProperty {
  84535. /**
  84536. * The index of the camera referenced by this node
  84537. */
  84538. camera?: number;
  84539. /**
  84540. * The indices of this node's children
  84541. */
  84542. children?: number[];
  84543. /**
  84544. * The index of the skin referenced by this node
  84545. */
  84546. skin?: number;
  84547. /**
  84548. * A floating-point 4x4 transformation matrix stored in column-major order
  84549. */
  84550. matrix?: number[];
  84551. /**
  84552. * The index of the mesh in this node
  84553. */
  84554. mesh?: number;
  84555. /**
  84556. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84557. */
  84558. rotation?: number[];
  84559. /**
  84560. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84561. */
  84562. scale?: number[];
  84563. /**
  84564. * The node's translation along the x, y, and z axes
  84565. */
  84566. translation?: number[];
  84567. /**
  84568. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84569. */
  84570. weights?: number[];
  84571. }
  84572. /**
  84573. * Texture sampler properties for filtering and wrapping modes
  84574. */
  84575. interface ISampler extends IChildRootProperty {
  84576. /**
  84577. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84578. */
  84579. magFilter?: TextureMagFilter;
  84580. /**
  84581. * Minification filter. All valid values correspond to WebGL enums
  84582. */
  84583. minFilter?: TextureMinFilter;
  84584. /**
  84585. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84586. */
  84587. wrapS?: TextureWrapMode;
  84588. /**
  84589. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84590. */
  84591. wrapT?: TextureWrapMode;
  84592. }
  84593. /**
  84594. * The root nodes of a scene
  84595. */
  84596. interface IScene extends IChildRootProperty {
  84597. /**
  84598. * The indices of each root node
  84599. */
  84600. nodes: number[];
  84601. }
  84602. /**
  84603. * Joints and matrices defining a skin
  84604. */
  84605. interface ISkin extends IChildRootProperty {
  84606. /**
  84607. * 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
  84608. */
  84609. inverseBindMatrices?: number;
  84610. /**
  84611. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84612. */
  84613. skeleton?: number;
  84614. /**
  84615. * 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)
  84616. */
  84617. joints: number[];
  84618. }
  84619. /**
  84620. * A texture and its sampler
  84621. */
  84622. interface ITexture extends IChildRootProperty {
  84623. /**
  84624. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84625. */
  84626. sampler?: number;
  84627. /**
  84628. * The index of the image used by this texture
  84629. */
  84630. source: number;
  84631. }
  84632. /**
  84633. * Reference to a texture
  84634. */
  84635. interface ITextureInfo extends IProperty {
  84636. /**
  84637. * The index of the texture
  84638. */
  84639. index: number;
  84640. /**
  84641. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84642. */
  84643. texCoord?: number;
  84644. }
  84645. /**
  84646. * The root object for a glTF asset
  84647. */
  84648. interface IGLTF extends IProperty {
  84649. /**
  84650. * An array of accessors. An accessor is a typed view into a bufferView
  84651. */
  84652. accessors?: IAccessor[];
  84653. /**
  84654. * An array of keyframe animations
  84655. */
  84656. animations?: IAnimation[];
  84657. /**
  84658. * Metadata about the glTF asset
  84659. */
  84660. asset: IAsset;
  84661. /**
  84662. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84663. */
  84664. buffers?: IBuffer[];
  84665. /**
  84666. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84667. */
  84668. bufferViews?: IBufferView[];
  84669. /**
  84670. * An array of cameras
  84671. */
  84672. cameras?: ICamera[];
  84673. /**
  84674. * Names of glTF extensions used somewhere in this asset
  84675. */
  84676. extensionsUsed?: string[];
  84677. /**
  84678. * Names of glTF extensions required to properly load this asset
  84679. */
  84680. extensionsRequired?: string[];
  84681. /**
  84682. * An array of images. An image defines data used to create a texture
  84683. */
  84684. images?: IImage[];
  84685. /**
  84686. * An array of materials. A material defines the appearance of a primitive
  84687. */
  84688. materials?: IMaterial[];
  84689. /**
  84690. * An array of meshes. A mesh is a set of primitives to be rendered
  84691. */
  84692. meshes?: IMesh[];
  84693. /**
  84694. * An array of nodes
  84695. */
  84696. nodes?: INode[];
  84697. /**
  84698. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84699. */
  84700. samplers?: ISampler[];
  84701. /**
  84702. * The index of the default scene
  84703. */
  84704. scene?: number;
  84705. /**
  84706. * An array of scenes
  84707. */
  84708. scenes?: IScene[];
  84709. /**
  84710. * An array of skins. A skin is defined by joints and matrices
  84711. */
  84712. skins?: ISkin[];
  84713. /**
  84714. * An array of textures
  84715. */
  84716. textures?: ITexture[];
  84717. }
  84718. /**
  84719. * The glTF validation results
  84720. * @ignore
  84721. */
  84722. interface IGLTFValidationResults {
  84723. info: {
  84724. generator: string;
  84725. hasAnimations: boolean;
  84726. hasDefaultScene: boolean;
  84727. hasMaterials: boolean;
  84728. hasMorphTargets: boolean;
  84729. hasSkins: boolean;
  84730. hasTextures: boolean;
  84731. maxAttributesUsed: number;
  84732. primitivesCount: number
  84733. };
  84734. issues: {
  84735. messages: Array<string>;
  84736. numErrors: number;
  84737. numHints: number;
  84738. numInfos: number;
  84739. numWarnings: number;
  84740. truncated: boolean
  84741. };
  84742. mimeType: string;
  84743. uri: string;
  84744. validatedAt: string;
  84745. validatorVersion: string;
  84746. }
  84747. /**
  84748. * The glTF validation options
  84749. */
  84750. interface IGLTFValidationOptions {
  84751. /** Uri to use */
  84752. uri?: string;
  84753. /** Function used to load external resources */
  84754. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84755. /** Boolean indicating that we need to validate accessor data */
  84756. validateAccessorData?: boolean;
  84757. /** max number of issues allowed */
  84758. maxIssues?: number;
  84759. /** Ignored issues */
  84760. ignoredIssues?: Array<string>;
  84761. /** Value to override severy settings */
  84762. severityOverrides?: Object;
  84763. }
  84764. /**
  84765. * The glTF validator object
  84766. * @ignore
  84767. */
  84768. interface IGLTFValidator {
  84769. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84770. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84771. }
  84772. /**
  84773. * Interfaces from the EXT_lights_image_based extension
  84774. */
  84775. /** @hidden */
  84776. interface IEXTLightsImageBased_LightReferenceImageBased {
  84777. light: number;
  84778. }
  84779. /** @hidden */
  84780. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84781. intensity: number;
  84782. rotation: number[];
  84783. specularImageSize: number;
  84784. specularImages: number[][];
  84785. irradianceCoefficients: number[][];
  84786. }
  84787. /** @hidden */
  84788. interface IEXTLightsImageBased {
  84789. lights: IEXTLightsImageBased_LightImageBased[];
  84790. }
  84791. /**
  84792. * Interfaces from the EXT_mesh_gpu_instancing extension
  84793. * !!! Experimental Extension Subject to Changes !!!
  84794. */
  84795. /** @hidden */
  84796. interface IEXTMeshGpuInstancing {
  84797. mesh?: number;
  84798. attributes: { [name: string]: number };
  84799. }
  84800. /**
  84801. * Interfaces from the KHR_draco_mesh_compression extension
  84802. */
  84803. /** @hidden */
  84804. interface IKHRDracoMeshCompression {
  84805. bufferView: number;
  84806. attributes: { [name: string]: number };
  84807. }
  84808. /**
  84809. * Interfaces from the KHR_lights_punctual extension
  84810. */
  84811. /** @hidden */
  84812. const enum IKHRLightsPunctual_LightType {
  84813. DIRECTIONAL = "directional",
  84814. POINT = "point",
  84815. SPOT = "spot"
  84816. }
  84817. /** @hidden */
  84818. interface IKHRLightsPunctual_LightReference {
  84819. light: number;
  84820. }
  84821. /** @hidden */
  84822. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84823. type: IKHRLightsPunctual_LightType;
  84824. color?: number[];
  84825. intensity?: number;
  84826. range?: number;
  84827. spot?: {
  84828. innerConeAngle?: number;
  84829. outerConeAngle?: number;
  84830. };
  84831. }
  84832. /** @hidden */
  84833. interface IKHRLightsPunctual {
  84834. lights: IKHRLightsPunctual_Light[];
  84835. }
  84836. /**
  84837. * Interfaces from the KHR_materials_clearcoat extension
  84838. * !!! Experimental Extension Subject to Changes !!!
  84839. */
  84840. /** @hidden */
  84841. interface IKHRMaterialsClearcoat {
  84842. clearcoatFactor: number;
  84843. clearcoatTexture: ITextureInfo;
  84844. clearcoatRoughnessFactor: number;
  84845. clearcoatRoughnessTexture: ITextureInfo;
  84846. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84847. }
  84848. /**
  84849. * Interfaces from the KHR_materials_ior extension
  84850. * !!! Experimental Extension Subject to Changes !!!
  84851. */
  84852. /** @hidden */
  84853. interface IKHRMaterialsIor {
  84854. ior: number;
  84855. }
  84856. /**
  84857. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84858. */
  84859. /** @hidden */
  84860. interface IKHRMaterialsPbrSpecularGlossiness {
  84861. diffuseFactor: number[];
  84862. diffuseTexture: ITextureInfo;
  84863. specularFactor: number[];
  84864. glossinessFactor: number;
  84865. specularGlossinessTexture: ITextureInfo;
  84866. }
  84867. /**
  84868. * Interfaces from the KHR_materials_sheen extension
  84869. * !!! Experimental Extension Subject to Changes !!!
  84870. */
  84871. /** @hidden */
  84872. interface IKHRMaterialsSheen {
  84873. sheenColorFactor?: number[];
  84874. sheenTexture?: ITextureInfo;
  84875. sheenRoughnessFactor?: number;
  84876. }
  84877. /**
  84878. * Interfaces from the KHR_materials_specular extension
  84879. * !!! Experimental Extension Subject to Changes !!!
  84880. */
  84881. /** @hidden */
  84882. interface IKHRMaterialsSpecular {
  84883. specularFactor: number;
  84884. specularColorFactor: number[];
  84885. specularTexture: ITextureInfo;
  84886. }
  84887. /**
  84888. * Interfaces from the KHR_materials_transmission extension
  84889. * !!! Experimental Extension Subject to Changes !!!
  84890. */
  84891. /** @hidden */
  84892. interface IKHRMaterialsTransmission {
  84893. transmissionFactor?: number;
  84894. transmissionTexture?: ITextureInfo;
  84895. }
  84896. /**
  84897. * Interfaces from the KHR_materials_variants extension
  84898. * !!! Experimental Extension Subject to Changes !!!
  84899. */
  84900. /** @hidden */
  84901. interface IKHRMaterialVariants_Mapping extends IProperty {
  84902. mapping: Array<{
  84903. variants: number[];
  84904. material: number;
  84905. }>;
  84906. }
  84907. /** @hidden */
  84908. interface IKHRMaterialVariants_Variant extends IProperty {
  84909. name: string;
  84910. }
  84911. /** @hidden */
  84912. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  84913. variants: Array<IKHRMaterialVariants_Variant>;
  84914. }
  84915. /**
  84916. * Interfaces from the KHR_texture_basisu extension
  84917. * !!! Experimental Extension Subject to Changes !!!
  84918. */
  84919. /** @hidden */
  84920. interface IKHRTextureBasisU {
  84921. source: number;
  84922. }
  84923. /**
  84924. * Interfaces from the EXT_texture_webp extension
  84925. */
  84926. /** @hidden */
  84927. interface IEXTTextureWebP {
  84928. source: number;
  84929. }
  84930. /**
  84931. * Interfaces from the KHR_texture_transform extension
  84932. */
  84933. /** @hidden */
  84934. interface IKHRTextureTransform {
  84935. offset?: number[];
  84936. rotation?: number;
  84937. scale?: number[];
  84938. texCoord?: number;
  84939. }
  84940. /**
  84941. * Interfaces from the KHR_xmp extension
  84942. * !!! Experimental Extension Subject to Changes !!!
  84943. */
  84944. /** @hidden */
  84945. interface IKHRXmp_Data {
  84946. [key: string]: unknown;
  84947. }
  84948. /** @hidden */
  84949. interface IKHRXmp_Gltf {
  84950. packets: IKHRXmp_Data[];
  84951. }
  84952. /** @hidden */
  84953. interface IKHRXmp_Node {
  84954. packet: number;
  84955. }
  84956. /**
  84957. * Interfaces from the MSFT_audio_emitter extension
  84958. */
  84959. /** @hidden */
  84960. interface IMSFTAudioEmitter_ClipReference {
  84961. clip: number;
  84962. weight?: number;
  84963. }
  84964. /** @hidden */
  84965. interface IMSFTAudioEmitter_EmittersReference {
  84966. emitters: number[];
  84967. }
  84968. /** @hidden */
  84969. const enum IMSFTAudioEmitter_DistanceModel {
  84970. linear = "linear",
  84971. inverse = "inverse",
  84972. exponential = "exponential",
  84973. }
  84974. /** @hidden */
  84975. interface IMSFTAudioEmitter_Emitter {
  84976. name?: string;
  84977. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84978. refDistance?: number;
  84979. maxDistance?: number;
  84980. rolloffFactor?: number;
  84981. innerAngle?: number;
  84982. outerAngle?: number;
  84983. loop?: boolean;
  84984. volume?: number;
  84985. clips: IMSFTAudioEmitter_ClipReference[];
  84986. }
  84987. /** @hidden */
  84988. const enum IMSFTAudioEmitter_AudioMimeType {
  84989. WAV = "audio/wav",
  84990. }
  84991. /** @hidden */
  84992. interface IMSFTAudioEmitter_Clip extends IProperty {
  84993. uri?: string;
  84994. bufferView?: number;
  84995. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84996. }
  84997. /** @hidden */
  84998. const enum IMSFTAudioEmitter_AnimationEventAction {
  84999. play = "play",
  85000. pause = "pause",
  85001. stop = "stop",
  85002. }
  85003. /** @hidden */
  85004. interface IMSFTAudioEmitter_AnimationEvent {
  85005. action: IMSFTAudioEmitter_AnimationEventAction;
  85006. emitter: number;
  85007. time: number;
  85008. startOffset?: number;
  85009. }
  85010. /**
  85011. * Interfaces from the MSFT_lod extension
  85012. */
  85013. /** @hidden */
  85014. interface IMSFTLOD {
  85015. ids: number[];
  85016. }
  85017. }
  85018. declare module BABYLON {
  85019. /** @hidden */
  85020. export var cellPixelShader: {
  85021. name: string;
  85022. shader: string;
  85023. };
  85024. }
  85025. declare module BABYLON {
  85026. /** @hidden */
  85027. export var cellVertexShader: {
  85028. name: string;
  85029. shader: string;
  85030. };
  85031. }
  85032. declare module BABYLON {
  85033. export class CellMaterial extends BABYLON.PushMaterial {
  85034. private _diffuseTexture;
  85035. diffuseTexture: BABYLON.BaseTexture;
  85036. diffuseColor: BABYLON.Color3;
  85037. _computeHighLevel: boolean;
  85038. computeHighLevel: boolean;
  85039. private _disableLighting;
  85040. disableLighting: boolean;
  85041. private _maxSimultaneousLights;
  85042. maxSimultaneousLights: number;
  85043. constructor(name: string, scene: BABYLON.Scene);
  85044. needAlphaBlending(): boolean;
  85045. needAlphaTesting(): boolean;
  85046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85047. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85048. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85049. getAnimatables(): BABYLON.IAnimatable[];
  85050. getActiveTextures(): BABYLON.BaseTexture[];
  85051. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85052. dispose(forceDisposeEffect?: boolean): void;
  85053. getClassName(): string;
  85054. clone(name: string): CellMaterial;
  85055. serialize(): any;
  85056. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85057. }
  85058. }
  85059. declare module BABYLON {
  85060. export class CustomShaderStructure {
  85061. FragmentStore: string;
  85062. VertexStore: string;
  85063. constructor();
  85064. }
  85065. export class ShaderSpecialParts {
  85066. constructor();
  85067. Fragment_Begin: string;
  85068. Fragment_Definitions: string;
  85069. Fragment_MainBegin: string;
  85070. Fragment_Custom_Diffuse: string;
  85071. Fragment_Before_Lights: string;
  85072. Fragment_Before_Fog: string;
  85073. Fragment_Custom_Alpha: string;
  85074. Fragment_Before_FragColor: string;
  85075. Vertex_Begin: string;
  85076. Vertex_Definitions: string;
  85077. Vertex_MainBegin: string;
  85078. Vertex_Before_PositionUpdated: string;
  85079. Vertex_Before_NormalUpdated: string;
  85080. Vertex_After_WorldPosComputed: string;
  85081. Vertex_MainEnd: string;
  85082. }
  85083. export class CustomMaterial extends BABYLON.StandardMaterial {
  85084. static ShaderIndexer: number;
  85085. CustomParts: ShaderSpecialParts;
  85086. _isCreatedShader: boolean;
  85087. _createdShaderName: string;
  85088. _customUniform: string[];
  85089. _newUniforms: string[];
  85090. _newUniformInstances: {
  85091. [name: string]: any;
  85092. };
  85093. _newSamplerInstances: {
  85094. [name: string]: BABYLON.Texture;
  85095. };
  85096. _customAttributes: string[];
  85097. FragmentShader: string;
  85098. VertexShader: string;
  85099. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85100. ReviewUniform(name: string, arr: string[]): string[];
  85101. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85102. constructor(name: string, scene: BABYLON.Scene);
  85103. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85104. AddAttribute(name: string): CustomMaterial;
  85105. Fragment_Begin(shaderPart: string): CustomMaterial;
  85106. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85107. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85108. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85109. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85110. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85111. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85112. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85113. Vertex_Begin(shaderPart: string): CustomMaterial;
  85114. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85115. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85116. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85117. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85118. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85119. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85120. }
  85121. }
  85122. declare module BABYLON {
  85123. export class ShaderAlebdoParts {
  85124. constructor();
  85125. Fragment_Begin: string;
  85126. Fragment_Definitions: string;
  85127. Fragment_MainBegin: string;
  85128. Fragment_Custom_Albedo: string;
  85129. Fragment_Before_Lights: string;
  85130. Fragment_Custom_MetallicRoughness: string;
  85131. Fragment_Custom_MicroSurface: string;
  85132. Fragment_Before_Fog: string;
  85133. Fragment_Custom_Alpha: string;
  85134. Fragment_Before_FragColor: string;
  85135. Vertex_Begin: string;
  85136. Vertex_Definitions: string;
  85137. Vertex_MainBegin: string;
  85138. Vertex_Before_PositionUpdated: string;
  85139. Vertex_Before_NormalUpdated: string;
  85140. Vertex_After_WorldPosComputed: string;
  85141. Vertex_MainEnd: string;
  85142. }
  85143. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85144. static ShaderIndexer: number;
  85145. CustomParts: ShaderAlebdoParts;
  85146. _isCreatedShader: boolean;
  85147. _createdShaderName: string;
  85148. _customUniform: string[];
  85149. _newUniforms: string[];
  85150. _newUniformInstances: {
  85151. [name: string]: any;
  85152. };
  85153. _newSamplerInstances: {
  85154. [name: string]: BABYLON.Texture;
  85155. };
  85156. _customAttributes: string[];
  85157. FragmentShader: string;
  85158. VertexShader: string;
  85159. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85160. ReviewUniform(name: string, arr: string[]): string[];
  85161. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85162. constructor(name: string, scene: BABYLON.Scene);
  85163. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85164. AddAttribute(name: string): PBRCustomMaterial;
  85165. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85166. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85167. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85168. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85169. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85170. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85171. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85172. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85173. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85174. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85175. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85176. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85177. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85178. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85179. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85180. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85181. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85182. }
  85183. }
  85184. declare module BABYLON {
  85185. /** @hidden */
  85186. export var firePixelShader: {
  85187. name: string;
  85188. shader: string;
  85189. };
  85190. }
  85191. declare module BABYLON {
  85192. /** @hidden */
  85193. export var fireVertexShader: {
  85194. name: string;
  85195. shader: string;
  85196. };
  85197. }
  85198. declare module BABYLON {
  85199. export class FireMaterial extends BABYLON.PushMaterial {
  85200. private _diffuseTexture;
  85201. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85202. private _distortionTexture;
  85203. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85204. private _opacityTexture;
  85205. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85206. diffuseColor: BABYLON.Color3;
  85207. speed: number;
  85208. private _scaledDiffuse;
  85209. private _lastTime;
  85210. constructor(name: string, scene: BABYLON.Scene);
  85211. needAlphaBlending(): boolean;
  85212. needAlphaTesting(): boolean;
  85213. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85214. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85215. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85216. getAnimatables(): BABYLON.IAnimatable[];
  85217. getActiveTextures(): BABYLON.BaseTexture[];
  85218. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85219. getClassName(): string;
  85220. dispose(forceDisposeEffect?: boolean): void;
  85221. clone(name: string): FireMaterial;
  85222. serialize(): any;
  85223. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85224. }
  85225. }
  85226. declare module BABYLON {
  85227. /** @hidden */
  85228. export var furPixelShader: {
  85229. name: string;
  85230. shader: string;
  85231. };
  85232. }
  85233. declare module BABYLON {
  85234. /** @hidden */
  85235. export var furVertexShader: {
  85236. name: string;
  85237. shader: string;
  85238. };
  85239. }
  85240. declare module BABYLON {
  85241. export class FurMaterial extends BABYLON.PushMaterial {
  85242. private _diffuseTexture;
  85243. diffuseTexture: BABYLON.BaseTexture;
  85244. private _heightTexture;
  85245. heightTexture: BABYLON.BaseTexture;
  85246. diffuseColor: BABYLON.Color3;
  85247. furLength: number;
  85248. furAngle: number;
  85249. furColor: BABYLON.Color3;
  85250. furOffset: number;
  85251. furSpacing: number;
  85252. furGravity: BABYLON.Vector3;
  85253. furSpeed: number;
  85254. furDensity: number;
  85255. furOcclusion: number;
  85256. furTexture: BABYLON.DynamicTexture;
  85257. private _disableLighting;
  85258. disableLighting: boolean;
  85259. private _maxSimultaneousLights;
  85260. maxSimultaneousLights: number;
  85261. highLevelFur: boolean;
  85262. _meshes: BABYLON.AbstractMesh[];
  85263. private _furTime;
  85264. constructor(name: string, scene: BABYLON.Scene);
  85265. get furTime(): number;
  85266. set furTime(furTime: number);
  85267. needAlphaBlending(): boolean;
  85268. needAlphaTesting(): boolean;
  85269. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85270. updateFur(): void;
  85271. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85272. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85273. getAnimatables(): BABYLON.IAnimatable[];
  85274. getActiveTextures(): BABYLON.BaseTexture[];
  85275. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85276. dispose(forceDisposeEffect?: boolean): void;
  85277. clone(name: string): FurMaterial;
  85278. serialize(): any;
  85279. getClassName(): string;
  85280. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85281. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85282. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85283. }
  85284. }
  85285. declare module BABYLON {
  85286. /** @hidden */
  85287. export var gradientPixelShader: {
  85288. name: string;
  85289. shader: string;
  85290. };
  85291. }
  85292. declare module BABYLON {
  85293. /** @hidden */
  85294. export var gradientVertexShader: {
  85295. name: string;
  85296. shader: string;
  85297. };
  85298. }
  85299. declare module BABYLON {
  85300. export class GradientMaterial extends BABYLON.PushMaterial {
  85301. private _maxSimultaneousLights;
  85302. maxSimultaneousLights: number;
  85303. topColor: BABYLON.Color3;
  85304. topColorAlpha: number;
  85305. bottomColor: BABYLON.Color3;
  85306. bottomColorAlpha: number;
  85307. offset: number;
  85308. scale: number;
  85309. smoothness: number;
  85310. private _disableLighting;
  85311. disableLighting: boolean;
  85312. constructor(name: string, scene: BABYLON.Scene);
  85313. needAlphaBlending(): boolean;
  85314. needAlphaTesting(): boolean;
  85315. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85316. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85317. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85318. getAnimatables(): BABYLON.IAnimatable[];
  85319. dispose(forceDisposeEffect?: boolean): void;
  85320. clone(name: string): GradientMaterial;
  85321. serialize(): any;
  85322. getClassName(): string;
  85323. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85324. }
  85325. }
  85326. declare module BABYLON {
  85327. /** @hidden */
  85328. export var gridPixelShader: {
  85329. name: string;
  85330. shader: string;
  85331. };
  85332. }
  85333. declare module BABYLON {
  85334. /** @hidden */
  85335. export var gridVertexShader: {
  85336. name: string;
  85337. shader: string;
  85338. };
  85339. }
  85340. declare module BABYLON {
  85341. /**
  85342. * The grid materials allows you to wrap any shape with a grid.
  85343. * Colors are customizable.
  85344. */
  85345. export class GridMaterial extends BABYLON.PushMaterial {
  85346. /**
  85347. * Main color of the grid (e.g. between lines)
  85348. */
  85349. mainColor: BABYLON.Color3;
  85350. /**
  85351. * Color of the grid lines.
  85352. */
  85353. lineColor: BABYLON.Color3;
  85354. /**
  85355. * The scale of the grid compared to unit.
  85356. */
  85357. gridRatio: number;
  85358. /**
  85359. * Allows setting an offset for the grid lines.
  85360. */
  85361. gridOffset: BABYLON.Vector3;
  85362. /**
  85363. * The frequency of thicker lines.
  85364. */
  85365. majorUnitFrequency: number;
  85366. /**
  85367. * The visibility of minor units in the grid.
  85368. */
  85369. minorUnitVisibility: number;
  85370. /**
  85371. * The grid opacity outside of the lines.
  85372. */
  85373. opacity: number;
  85374. /**
  85375. * Determine RBG output is premultiplied by alpha value.
  85376. */
  85377. preMultiplyAlpha: boolean;
  85378. private _opacityTexture;
  85379. opacityTexture: BABYLON.BaseTexture;
  85380. private _gridControl;
  85381. /**
  85382. * constructor
  85383. * @param name The name given to the material in order to identify it afterwards.
  85384. * @param scene The scene the material is used in.
  85385. */
  85386. constructor(name: string, scene: BABYLON.Scene);
  85387. /**
  85388. * Returns wehter or not the grid requires alpha blending.
  85389. */
  85390. needAlphaBlending(): boolean;
  85391. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85392. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85393. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85394. /**
  85395. * Dispose the material and its associated resources.
  85396. * @param forceDisposeEffect will also dispose the used effect when true
  85397. */
  85398. dispose(forceDisposeEffect?: boolean): void;
  85399. clone(name: string): GridMaterial;
  85400. serialize(): any;
  85401. getClassName(): string;
  85402. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85403. }
  85404. }
  85405. declare module BABYLON {
  85406. /** @hidden */
  85407. export var lavaPixelShader: {
  85408. name: string;
  85409. shader: string;
  85410. };
  85411. }
  85412. declare module BABYLON {
  85413. /** @hidden */
  85414. export var lavaVertexShader: {
  85415. name: string;
  85416. shader: string;
  85417. };
  85418. }
  85419. declare module BABYLON {
  85420. export class LavaMaterial extends BABYLON.PushMaterial {
  85421. private _diffuseTexture;
  85422. diffuseTexture: BABYLON.BaseTexture;
  85423. noiseTexture: BABYLON.BaseTexture;
  85424. fogColor: BABYLON.Color3;
  85425. speed: number;
  85426. movingSpeed: number;
  85427. lowFrequencySpeed: number;
  85428. fogDensity: number;
  85429. private _lastTime;
  85430. diffuseColor: BABYLON.Color3;
  85431. private _disableLighting;
  85432. disableLighting: boolean;
  85433. private _unlit;
  85434. unlit: boolean;
  85435. private _maxSimultaneousLights;
  85436. maxSimultaneousLights: number;
  85437. private _scaledDiffuse;
  85438. constructor(name: string, scene: BABYLON.Scene);
  85439. needAlphaBlending(): boolean;
  85440. needAlphaTesting(): boolean;
  85441. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85442. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85443. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85444. getAnimatables(): BABYLON.IAnimatable[];
  85445. getActiveTextures(): BABYLON.BaseTexture[];
  85446. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85447. dispose(forceDisposeEffect?: boolean): void;
  85448. clone(name: string): LavaMaterial;
  85449. serialize(): any;
  85450. getClassName(): string;
  85451. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85452. }
  85453. }
  85454. declare module BABYLON {
  85455. /** @hidden */
  85456. export var mixPixelShader: {
  85457. name: string;
  85458. shader: string;
  85459. };
  85460. }
  85461. declare module BABYLON {
  85462. /** @hidden */
  85463. export var mixVertexShader: {
  85464. name: string;
  85465. shader: string;
  85466. };
  85467. }
  85468. declare module BABYLON {
  85469. export class MixMaterial extends BABYLON.PushMaterial {
  85470. /**
  85471. * Mix textures
  85472. */
  85473. private _mixTexture1;
  85474. mixTexture1: BABYLON.BaseTexture;
  85475. private _mixTexture2;
  85476. mixTexture2: BABYLON.BaseTexture;
  85477. /**
  85478. * Diffuse textures
  85479. */
  85480. private _diffuseTexture1;
  85481. diffuseTexture1: BABYLON.Texture;
  85482. private _diffuseTexture2;
  85483. diffuseTexture2: BABYLON.Texture;
  85484. private _diffuseTexture3;
  85485. diffuseTexture3: BABYLON.Texture;
  85486. private _diffuseTexture4;
  85487. diffuseTexture4: BABYLON.Texture;
  85488. private _diffuseTexture5;
  85489. diffuseTexture5: BABYLON.Texture;
  85490. private _diffuseTexture6;
  85491. diffuseTexture6: BABYLON.Texture;
  85492. private _diffuseTexture7;
  85493. diffuseTexture7: BABYLON.Texture;
  85494. private _diffuseTexture8;
  85495. diffuseTexture8: BABYLON.Texture;
  85496. /**
  85497. * Uniforms
  85498. */
  85499. diffuseColor: BABYLON.Color3;
  85500. specularColor: BABYLON.Color3;
  85501. specularPower: number;
  85502. private _disableLighting;
  85503. disableLighting: boolean;
  85504. private _maxSimultaneousLights;
  85505. maxSimultaneousLights: number;
  85506. constructor(name: string, scene: BABYLON.Scene);
  85507. needAlphaBlending(): boolean;
  85508. needAlphaTesting(): boolean;
  85509. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85510. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85511. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85512. getAnimatables(): BABYLON.IAnimatable[];
  85513. getActiveTextures(): BABYLON.BaseTexture[];
  85514. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85515. dispose(forceDisposeEffect?: boolean): void;
  85516. clone(name: string): MixMaterial;
  85517. serialize(): any;
  85518. getClassName(): string;
  85519. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85520. }
  85521. }
  85522. declare module BABYLON {
  85523. /** @hidden */
  85524. export var normalPixelShader: {
  85525. name: string;
  85526. shader: string;
  85527. };
  85528. }
  85529. declare module BABYLON {
  85530. /** @hidden */
  85531. export var normalVertexShader: {
  85532. name: string;
  85533. shader: string;
  85534. };
  85535. }
  85536. declare module BABYLON {
  85537. export class NormalMaterial extends BABYLON.PushMaterial {
  85538. private _diffuseTexture;
  85539. diffuseTexture: BABYLON.BaseTexture;
  85540. diffuseColor: BABYLON.Color3;
  85541. private _disableLighting;
  85542. disableLighting: boolean;
  85543. private _maxSimultaneousLights;
  85544. maxSimultaneousLights: number;
  85545. constructor(name: string, scene: BABYLON.Scene);
  85546. needAlphaBlending(): boolean;
  85547. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85548. needAlphaTesting(): boolean;
  85549. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85550. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85551. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85552. getAnimatables(): BABYLON.IAnimatable[];
  85553. getActiveTextures(): BABYLON.BaseTexture[];
  85554. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85555. dispose(forceDisposeEffect?: boolean): void;
  85556. clone(name: string): NormalMaterial;
  85557. serialize(): any;
  85558. getClassName(): string;
  85559. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85560. }
  85561. }
  85562. declare module BABYLON {
  85563. /** @hidden */
  85564. export var shadowOnlyPixelShader: {
  85565. name: string;
  85566. shader: string;
  85567. };
  85568. }
  85569. declare module BABYLON {
  85570. /** @hidden */
  85571. export var shadowOnlyVertexShader: {
  85572. name: string;
  85573. shader: string;
  85574. };
  85575. }
  85576. declare module BABYLON {
  85577. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85578. private _activeLight;
  85579. private _needAlphaBlending;
  85580. constructor(name: string, scene: BABYLON.Scene);
  85581. shadowColor: BABYLON.Color3;
  85582. needAlphaBlending(): boolean;
  85583. needAlphaTesting(): boolean;
  85584. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85585. get activeLight(): BABYLON.IShadowLight;
  85586. set activeLight(light: BABYLON.IShadowLight);
  85587. private _getFirstShadowLightForMesh;
  85588. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85589. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85590. clone(name: string): ShadowOnlyMaterial;
  85591. serialize(): any;
  85592. getClassName(): string;
  85593. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85594. }
  85595. }
  85596. declare module BABYLON {
  85597. /** @hidden */
  85598. export var simplePixelShader: {
  85599. name: string;
  85600. shader: string;
  85601. };
  85602. }
  85603. declare module BABYLON {
  85604. /** @hidden */
  85605. export var simpleVertexShader: {
  85606. name: string;
  85607. shader: string;
  85608. };
  85609. }
  85610. declare module BABYLON {
  85611. export class SimpleMaterial extends BABYLON.PushMaterial {
  85612. private _diffuseTexture;
  85613. diffuseTexture: BABYLON.BaseTexture;
  85614. diffuseColor: BABYLON.Color3;
  85615. private _disableLighting;
  85616. disableLighting: boolean;
  85617. private _maxSimultaneousLights;
  85618. maxSimultaneousLights: number;
  85619. constructor(name: string, scene: BABYLON.Scene);
  85620. needAlphaBlending(): boolean;
  85621. needAlphaTesting(): boolean;
  85622. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85623. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85624. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85625. getAnimatables(): BABYLON.IAnimatable[];
  85626. getActiveTextures(): BABYLON.BaseTexture[];
  85627. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85628. dispose(forceDisposeEffect?: boolean): void;
  85629. clone(name: string): SimpleMaterial;
  85630. serialize(): any;
  85631. getClassName(): string;
  85632. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85633. }
  85634. }
  85635. declare module BABYLON {
  85636. /** @hidden */
  85637. export var skyPixelShader: {
  85638. name: string;
  85639. shader: string;
  85640. };
  85641. }
  85642. declare module BABYLON {
  85643. /** @hidden */
  85644. export var skyVertexShader: {
  85645. name: string;
  85646. shader: string;
  85647. };
  85648. }
  85649. declare module BABYLON {
  85650. /**
  85651. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85652. * @see https://doc.babylonjs.com/extensions/sky
  85653. */
  85654. export class SkyMaterial extends BABYLON.PushMaterial {
  85655. /**
  85656. * Defines the overall luminance of sky in interval ]0, 1[.
  85657. */
  85658. luminance: number;
  85659. /**
  85660. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85661. */
  85662. turbidity: number;
  85663. /**
  85664. * Defines the sky appearance (light intensity).
  85665. */
  85666. rayleigh: number;
  85667. /**
  85668. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85669. */
  85670. mieCoefficient: number;
  85671. /**
  85672. * Defines the amount of haze particles following the Mie scattering theory.
  85673. */
  85674. mieDirectionalG: number;
  85675. /**
  85676. * Defines the distance of the sun according to the active scene camera.
  85677. */
  85678. distance: number;
  85679. /**
  85680. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85681. * "inclined".
  85682. */
  85683. inclination: number;
  85684. /**
  85685. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85686. * an object direction and a reference direction.
  85687. */
  85688. azimuth: number;
  85689. /**
  85690. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85691. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85692. */
  85693. sunPosition: BABYLON.Vector3;
  85694. /**
  85695. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85696. * .sunPosition property.
  85697. */
  85698. useSunPosition: boolean;
  85699. /**
  85700. * Defines an offset vector used to get a horizon offset.
  85701. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85702. */
  85703. cameraOffset: BABYLON.Vector3;
  85704. private _cameraPosition;
  85705. /**
  85706. * Instantiates a new sky material.
  85707. * This material allows to create dynamic and texture free
  85708. * effects for skyboxes by taking care of the atmosphere state.
  85709. * @see https://doc.babylonjs.com/extensions/sky
  85710. * @param name Define the name of the material in the scene
  85711. * @param scene Define the scene the material belong to
  85712. */
  85713. constructor(name: string, scene: BABYLON.Scene);
  85714. /**
  85715. * Specifies if the material will require alpha blending
  85716. * @returns a boolean specifying if alpha blending is needed
  85717. */
  85718. needAlphaBlending(): boolean;
  85719. /**
  85720. * Specifies if this material should be rendered in alpha test mode
  85721. * @returns false as the sky material doesn't need alpha testing.
  85722. */
  85723. needAlphaTesting(): boolean;
  85724. /**
  85725. * Get the texture used for alpha test purpose.
  85726. * @returns null as the sky material has no texture.
  85727. */
  85728. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85729. /**
  85730. * Get if the submesh is ready to be used and all its information available.
  85731. * Child classes can use it to update shaders
  85732. * @param mesh defines the mesh to check
  85733. * @param subMesh defines which submesh to check
  85734. * @param useInstances specifies that instances should be used
  85735. * @returns a boolean indicating that the submesh is ready or not
  85736. */
  85737. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85738. /**
  85739. * Binds the submesh to this material by preparing the effect and shader to draw
  85740. * @param world defines the world transformation matrix
  85741. * @param mesh defines the mesh containing the submesh
  85742. * @param subMesh defines the submesh to bind the material to
  85743. */
  85744. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85745. /**
  85746. * Get the list of animatables in the material.
  85747. * @returns the list of animatables object used in the material
  85748. */
  85749. getAnimatables(): BABYLON.IAnimatable[];
  85750. /**
  85751. * Disposes the material
  85752. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85753. */
  85754. dispose(forceDisposeEffect?: boolean): void;
  85755. /**
  85756. * Makes a duplicate of the material, and gives it a new name
  85757. * @param name defines the new name for the duplicated material
  85758. * @returns the cloned material
  85759. */
  85760. clone(name: string): SkyMaterial;
  85761. /**
  85762. * Serializes this material in a JSON representation
  85763. * @returns the serialized material object
  85764. */
  85765. serialize(): any;
  85766. /**
  85767. * Gets the current class name of the material e.g. "SkyMaterial"
  85768. * Mainly use in serialization.
  85769. * @returns the class name
  85770. */
  85771. getClassName(): string;
  85772. /**
  85773. * Creates a sky material from parsed material data
  85774. * @param source defines the JSON representation of the material
  85775. * @param scene defines the hosting scene
  85776. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85777. * @returns a new sky material
  85778. */
  85779. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85780. }
  85781. }
  85782. declare module BABYLON {
  85783. /** @hidden */
  85784. export var terrainPixelShader: {
  85785. name: string;
  85786. shader: string;
  85787. };
  85788. }
  85789. declare module BABYLON {
  85790. /** @hidden */
  85791. export var terrainVertexShader: {
  85792. name: string;
  85793. shader: string;
  85794. };
  85795. }
  85796. declare module BABYLON {
  85797. export class TerrainMaterial extends BABYLON.PushMaterial {
  85798. private _mixTexture;
  85799. mixTexture: BABYLON.BaseTexture;
  85800. private _diffuseTexture1;
  85801. diffuseTexture1: BABYLON.Texture;
  85802. private _diffuseTexture2;
  85803. diffuseTexture2: BABYLON.Texture;
  85804. private _diffuseTexture3;
  85805. diffuseTexture3: BABYLON.Texture;
  85806. private _bumpTexture1;
  85807. bumpTexture1: BABYLON.Texture;
  85808. private _bumpTexture2;
  85809. bumpTexture2: BABYLON.Texture;
  85810. private _bumpTexture3;
  85811. bumpTexture3: BABYLON.Texture;
  85812. diffuseColor: BABYLON.Color3;
  85813. specularColor: BABYLON.Color3;
  85814. specularPower: number;
  85815. private _disableLighting;
  85816. disableLighting: boolean;
  85817. private _maxSimultaneousLights;
  85818. maxSimultaneousLights: number;
  85819. constructor(name: string, scene: BABYLON.Scene);
  85820. needAlphaBlending(): boolean;
  85821. needAlphaTesting(): boolean;
  85822. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85823. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85824. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85825. getAnimatables(): BABYLON.IAnimatable[];
  85826. getActiveTextures(): BABYLON.BaseTexture[];
  85827. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85828. dispose(forceDisposeEffect?: boolean): void;
  85829. clone(name: string): TerrainMaterial;
  85830. serialize(): any;
  85831. getClassName(): string;
  85832. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85833. }
  85834. }
  85835. declare module BABYLON {
  85836. /** @hidden */
  85837. export var triplanarPixelShader: {
  85838. name: string;
  85839. shader: string;
  85840. };
  85841. }
  85842. declare module BABYLON {
  85843. /** @hidden */
  85844. export var triplanarVertexShader: {
  85845. name: string;
  85846. shader: string;
  85847. };
  85848. }
  85849. declare module BABYLON {
  85850. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85851. mixTexture: BABYLON.BaseTexture;
  85852. private _diffuseTextureX;
  85853. diffuseTextureX: BABYLON.BaseTexture;
  85854. private _diffuseTextureY;
  85855. diffuseTextureY: BABYLON.BaseTexture;
  85856. private _diffuseTextureZ;
  85857. diffuseTextureZ: BABYLON.BaseTexture;
  85858. private _normalTextureX;
  85859. normalTextureX: BABYLON.BaseTexture;
  85860. private _normalTextureY;
  85861. normalTextureY: BABYLON.BaseTexture;
  85862. private _normalTextureZ;
  85863. normalTextureZ: BABYLON.BaseTexture;
  85864. tileSize: number;
  85865. diffuseColor: BABYLON.Color3;
  85866. specularColor: BABYLON.Color3;
  85867. specularPower: number;
  85868. private _disableLighting;
  85869. disableLighting: boolean;
  85870. private _maxSimultaneousLights;
  85871. maxSimultaneousLights: number;
  85872. constructor(name: string, scene: BABYLON.Scene);
  85873. needAlphaBlending(): boolean;
  85874. needAlphaTesting(): boolean;
  85875. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85876. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85877. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85878. getAnimatables(): BABYLON.IAnimatable[];
  85879. getActiveTextures(): BABYLON.BaseTexture[];
  85880. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85881. dispose(forceDisposeEffect?: boolean): void;
  85882. clone(name: string): TriPlanarMaterial;
  85883. serialize(): any;
  85884. getClassName(): string;
  85885. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85886. }
  85887. }
  85888. declare module BABYLON {
  85889. /** @hidden */
  85890. export var waterPixelShader: {
  85891. name: string;
  85892. shader: string;
  85893. };
  85894. }
  85895. declare module BABYLON {
  85896. /** @hidden */
  85897. export var waterVertexShader: {
  85898. name: string;
  85899. shader: string;
  85900. };
  85901. }
  85902. declare module BABYLON {
  85903. export class WaterMaterial extends BABYLON.PushMaterial {
  85904. renderTargetSize: BABYLON.Vector2;
  85905. private _bumpTexture;
  85906. bumpTexture: BABYLON.BaseTexture;
  85907. diffuseColor: BABYLON.Color3;
  85908. specularColor: BABYLON.Color3;
  85909. specularPower: number;
  85910. private _disableLighting;
  85911. disableLighting: boolean;
  85912. private _maxSimultaneousLights;
  85913. maxSimultaneousLights: number;
  85914. /**
  85915. * @param {number}: Represents the wind force
  85916. */
  85917. windForce: number;
  85918. /**
  85919. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85920. */
  85921. windDirection: BABYLON.Vector2;
  85922. /**
  85923. * @param {number}: Wave height, represents the height of the waves
  85924. */
  85925. waveHeight: number;
  85926. /**
  85927. * @param {number}: Bump height, represents the bump height related to the bump map
  85928. */
  85929. bumpHeight: number;
  85930. /**
  85931. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85932. */
  85933. private _bumpSuperimpose;
  85934. bumpSuperimpose: boolean;
  85935. /**
  85936. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85937. */
  85938. private _fresnelSeparate;
  85939. fresnelSeparate: boolean;
  85940. /**
  85941. * @param {boolean}: bump Waves modify the reflection.
  85942. */
  85943. private _bumpAffectsReflection;
  85944. bumpAffectsReflection: boolean;
  85945. /**
  85946. * @param {number}: The water color blended with the refraction (near)
  85947. */
  85948. waterColor: BABYLON.Color3;
  85949. /**
  85950. * @param {number}: The blend factor related to the water color
  85951. */
  85952. colorBlendFactor: number;
  85953. /**
  85954. * @param {number}: The water color blended with the reflection (far)
  85955. */
  85956. waterColor2: BABYLON.Color3;
  85957. /**
  85958. * @param {number}: The blend factor related to the water color (reflection, far)
  85959. */
  85960. colorBlendFactor2: number;
  85961. /**
  85962. * @param {number}: Represents the maximum length of a wave
  85963. */
  85964. waveLength: number;
  85965. /**
  85966. * @param {number}: Defines the waves speed
  85967. */
  85968. waveSpeed: number;
  85969. /**
  85970. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85971. * will avoid calculating useless pixels in the pixel shader of the water material.
  85972. */
  85973. disableClipPlane: boolean;
  85974. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85975. private _mesh;
  85976. private _refractionRTT;
  85977. private _reflectionRTT;
  85978. private _reflectionTransform;
  85979. private _lastTime;
  85980. private _lastDeltaTime;
  85981. private _useLogarithmicDepth;
  85982. private _waitingRenderList;
  85983. private _imageProcessingConfiguration;
  85984. private _imageProcessingObserver;
  85985. /**
  85986. * Gets a boolean indicating that current material needs to register RTT
  85987. */
  85988. get hasRenderTargetTextures(): boolean;
  85989. /**
  85990. * Constructor
  85991. */
  85992. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85993. get useLogarithmicDepth(): boolean;
  85994. set useLogarithmicDepth(value: boolean);
  85995. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85996. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85997. addToRenderList(node: any): void;
  85998. enableRenderTargets(enable: boolean): void;
  85999. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86000. get renderTargetsEnabled(): boolean;
  86001. needAlphaBlending(): boolean;
  86002. needAlphaTesting(): boolean;
  86003. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86004. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86005. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86006. private _createRenderTargets;
  86007. getAnimatables(): BABYLON.IAnimatable[];
  86008. getActiveTextures(): BABYLON.BaseTexture[];
  86009. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86010. dispose(forceDisposeEffect?: boolean): void;
  86011. clone(name: string): WaterMaterial;
  86012. serialize(): any;
  86013. getClassName(): string;
  86014. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86015. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86016. }
  86017. }
  86018. declare module BABYLON {
  86019. /** @hidden */
  86020. export var asciiartPixelShader: {
  86021. name: string;
  86022. shader: string;
  86023. };
  86024. }
  86025. declare module BABYLON {
  86026. /**
  86027. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86028. *
  86029. * It basically takes care rendering the font front the given font size to a texture.
  86030. * This is used later on in the postprocess.
  86031. */
  86032. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86033. private _font;
  86034. private _text;
  86035. private _charSize;
  86036. /**
  86037. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86038. */
  86039. get charSize(): number;
  86040. /**
  86041. * Create a new instance of the Ascii Art FontTexture class
  86042. * @param name the name of the texture
  86043. * @param font the font to use, use the W3C CSS notation
  86044. * @param text the caracter set to use in the rendering.
  86045. * @param scene the scene that owns the texture
  86046. */
  86047. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86048. /**
  86049. * Gets the max char width of a font.
  86050. * @param font the font to use, use the W3C CSS notation
  86051. * @return the max char width
  86052. */
  86053. private getFontWidth;
  86054. /**
  86055. * Gets the max char height of a font.
  86056. * @param font the font to use, use the W3C CSS notation
  86057. * @return the max char height
  86058. */
  86059. private getFontHeight;
  86060. /**
  86061. * Clones the current AsciiArtTexture.
  86062. * @return the clone of the texture.
  86063. */
  86064. clone(): AsciiArtFontTexture;
  86065. /**
  86066. * Parses a json object representing the texture and returns an instance of it.
  86067. * @param source the source JSON representation
  86068. * @param scene the scene to create the texture for
  86069. * @return the parsed texture
  86070. */
  86071. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86072. }
  86073. /**
  86074. * Option available in the Ascii Art Post Process.
  86075. */
  86076. export interface IAsciiArtPostProcessOptions {
  86077. /**
  86078. * The font to use following the w3c font definition.
  86079. */
  86080. font?: string;
  86081. /**
  86082. * The character set to use in the postprocess.
  86083. */
  86084. characterSet?: string;
  86085. /**
  86086. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86087. * This number is defined between 0 and 1;
  86088. */
  86089. mixToTile?: number;
  86090. /**
  86091. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86092. * This number is defined between 0 and 1;
  86093. */
  86094. mixToNormal?: number;
  86095. }
  86096. /**
  86097. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86098. *
  86099. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86100. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86101. */
  86102. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86103. /**
  86104. * The font texture used to render the char in the post process.
  86105. */
  86106. private _asciiArtFontTexture;
  86107. /**
  86108. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86109. * This number is defined between 0 and 1;
  86110. */
  86111. mixToTile: number;
  86112. /**
  86113. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86114. * This number is defined between 0 and 1;
  86115. */
  86116. mixToNormal: number;
  86117. /**
  86118. * Instantiates a new Ascii Art Post Process.
  86119. * @param name the name to give to the postprocess
  86120. * @camera the camera to apply the post process to.
  86121. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86122. */
  86123. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86124. }
  86125. }
  86126. declare module BABYLON {
  86127. /** @hidden */
  86128. export var digitalrainPixelShader: {
  86129. name: string;
  86130. shader: string;
  86131. };
  86132. }
  86133. declare module BABYLON {
  86134. /**
  86135. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86136. *
  86137. * It basically takes care rendering the font front the given font size to a texture.
  86138. * This is used later on in the postprocess.
  86139. */
  86140. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86141. private _font;
  86142. private _text;
  86143. private _charSize;
  86144. /**
  86145. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86146. */
  86147. get charSize(): number;
  86148. /**
  86149. * Create a new instance of the Digital Rain FontTexture class
  86150. * @param name the name of the texture
  86151. * @param font the font to use, use the W3C CSS notation
  86152. * @param text the caracter set to use in the rendering.
  86153. * @param scene the scene that owns the texture
  86154. */
  86155. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86156. /**
  86157. * Gets the max char width of a font.
  86158. * @param font the font to use, use the W3C CSS notation
  86159. * @return the max char width
  86160. */
  86161. private getFontWidth;
  86162. /**
  86163. * Gets the max char height of a font.
  86164. * @param font the font to use, use the W3C CSS notation
  86165. * @return the max char height
  86166. */
  86167. private getFontHeight;
  86168. /**
  86169. * Clones the current DigitalRainFontTexture.
  86170. * @return the clone of the texture.
  86171. */
  86172. clone(): DigitalRainFontTexture;
  86173. /**
  86174. * Parses a json object representing the texture and returns an instance of it.
  86175. * @param source the source JSON representation
  86176. * @param scene the scene to create the texture for
  86177. * @return the parsed texture
  86178. */
  86179. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86180. }
  86181. /**
  86182. * Option available in the Digital Rain Post Process.
  86183. */
  86184. export interface IDigitalRainPostProcessOptions {
  86185. /**
  86186. * The font to use following the w3c font definition.
  86187. */
  86188. font?: string;
  86189. /**
  86190. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86191. * This number is defined between 0 and 1;
  86192. */
  86193. mixToTile?: number;
  86194. /**
  86195. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86196. * This number is defined between 0 and 1;
  86197. */
  86198. mixToNormal?: number;
  86199. }
  86200. /**
  86201. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86202. *
  86203. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86204. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86205. */
  86206. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86207. /**
  86208. * The font texture used to render the char in the post process.
  86209. */
  86210. private _digitalRainFontTexture;
  86211. /**
  86212. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86213. * This number is defined between 0 and 1;
  86214. */
  86215. mixToTile: number;
  86216. /**
  86217. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86218. * This number is defined between 0 and 1;
  86219. */
  86220. mixToNormal: number;
  86221. /**
  86222. * Instantiates a new Digital Rain Post Process.
  86223. * @param name the name to give to the postprocess
  86224. * @camera the camera to apply the post process to.
  86225. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86226. */
  86227. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86228. }
  86229. }
  86230. declare module BABYLON {
  86231. /** @hidden */
  86232. export var brickProceduralTexturePixelShader: {
  86233. name: string;
  86234. shader: string;
  86235. };
  86236. }
  86237. declare module BABYLON {
  86238. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86239. private _numberOfBricksHeight;
  86240. private _numberOfBricksWidth;
  86241. private _jointColor;
  86242. private _brickColor;
  86243. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86244. updateShaderUniforms(): void;
  86245. get numberOfBricksHeight(): number;
  86246. set numberOfBricksHeight(value: number);
  86247. get numberOfBricksWidth(): number;
  86248. set numberOfBricksWidth(value: number);
  86249. get jointColor(): BABYLON.Color3;
  86250. set jointColor(value: BABYLON.Color3);
  86251. get brickColor(): BABYLON.Color3;
  86252. set brickColor(value: BABYLON.Color3);
  86253. /**
  86254. * Serializes this brick procedural texture
  86255. * @returns a serialized brick procedural texture object
  86256. */
  86257. serialize(): any;
  86258. /**
  86259. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86260. * @param parsedTexture defines parsed texture data
  86261. * @param scene defines the current scene
  86262. * @param rootUrl defines the root URL containing brick procedural texture information
  86263. * @returns a parsed Brick Procedural BABYLON.Texture
  86264. */
  86265. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86266. }
  86267. }
  86268. declare module BABYLON {
  86269. /** @hidden */
  86270. export var cloudProceduralTexturePixelShader: {
  86271. name: string;
  86272. shader: string;
  86273. };
  86274. }
  86275. declare module BABYLON {
  86276. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86277. private _skyColor;
  86278. private _cloudColor;
  86279. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86280. updateShaderUniforms(): void;
  86281. get skyColor(): BABYLON.Color4;
  86282. set skyColor(value: BABYLON.Color4);
  86283. get cloudColor(): BABYLON.Color4;
  86284. set cloudColor(value: BABYLON.Color4);
  86285. /**
  86286. * Serializes this cloud procedural texture
  86287. * @returns a serialized cloud procedural texture object
  86288. */
  86289. serialize(): any;
  86290. /**
  86291. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86292. * @param parsedTexture defines parsed texture data
  86293. * @param scene defines the current scene
  86294. * @param rootUrl defines the root URL containing cloud procedural texture information
  86295. * @returns a parsed Cloud Procedural BABYLON.Texture
  86296. */
  86297. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /** @hidden */
  86302. export var fireProceduralTexturePixelShader: {
  86303. name: string;
  86304. shader: string;
  86305. };
  86306. }
  86307. declare module BABYLON {
  86308. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86309. private _time;
  86310. private _speed;
  86311. private _autoGenerateTime;
  86312. private _fireColors;
  86313. private _alphaThreshold;
  86314. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86315. updateShaderUniforms(): void;
  86316. render(useCameraPostProcess?: boolean): void;
  86317. static get PurpleFireColors(): BABYLON.Color3[];
  86318. static get GreenFireColors(): BABYLON.Color3[];
  86319. static get RedFireColors(): BABYLON.Color3[];
  86320. static get BlueFireColors(): BABYLON.Color3[];
  86321. get autoGenerateTime(): boolean;
  86322. set autoGenerateTime(value: boolean);
  86323. get fireColors(): BABYLON.Color3[];
  86324. set fireColors(value: BABYLON.Color3[]);
  86325. get time(): number;
  86326. set time(value: number);
  86327. get speed(): BABYLON.Vector2;
  86328. set speed(value: BABYLON.Vector2);
  86329. get alphaThreshold(): number;
  86330. set alphaThreshold(value: number);
  86331. /**
  86332. * Serializes this fire procedural texture
  86333. * @returns a serialized fire procedural texture object
  86334. */
  86335. serialize(): any;
  86336. /**
  86337. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86338. * @param parsedTexture defines parsed texture data
  86339. * @param scene defines the current scene
  86340. * @param rootUrl defines the root URL containing fire procedural texture information
  86341. * @returns a parsed Fire Procedural BABYLON.Texture
  86342. */
  86343. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86344. }
  86345. }
  86346. declare module BABYLON {
  86347. /** @hidden */
  86348. export var grassProceduralTexturePixelShader: {
  86349. name: string;
  86350. shader: string;
  86351. };
  86352. }
  86353. declare module BABYLON {
  86354. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86355. private _grassColors;
  86356. private _groundColor;
  86357. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86358. updateShaderUniforms(): void;
  86359. get grassColors(): BABYLON.Color3[];
  86360. set grassColors(value: BABYLON.Color3[]);
  86361. get groundColor(): BABYLON.Color3;
  86362. set groundColor(value: BABYLON.Color3);
  86363. /**
  86364. * Serializes this grass procedural texture
  86365. * @returns a serialized grass procedural texture object
  86366. */
  86367. serialize(): any;
  86368. /**
  86369. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86370. * @param parsedTexture defines parsed texture data
  86371. * @param scene defines the current scene
  86372. * @param rootUrl defines the root URL containing grass procedural texture information
  86373. * @returns a parsed Grass Procedural BABYLON.Texture
  86374. */
  86375. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86376. }
  86377. }
  86378. declare module BABYLON {
  86379. /** @hidden */
  86380. export var marbleProceduralTexturePixelShader: {
  86381. name: string;
  86382. shader: string;
  86383. };
  86384. }
  86385. declare module BABYLON {
  86386. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86387. private _numberOfTilesHeight;
  86388. private _numberOfTilesWidth;
  86389. private _amplitude;
  86390. private _jointColor;
  86391. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86392. updateShaderUniforms(): void;
  86393. get numberOfTilesHeight(): number;
  86394. set numberOfTilesHeight(value: number);
  86395. get amplitude(): number;
  86396. set amplitude(value: number);
  86397. get numberOfTilesWidth(): number;
  86398. set numberOfTilesWidth(value: number);
  86399. get jointColor(): BABYLON.Color3;
  86400. set jointColor(value: BABYLON.Color3);
  86401. /**
  86402. * Serializes this marble procedural texture
  86403. * @returns a serialized marble procedural texture object
  86404. */
  86405. serialize(): any;
  86406. /**
  86407. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86408. * @param parsedTexture defines parsed texture data
  86409. * @param scene defines the current scene
  86410. * @param rootUrl defines the root URL containing marble procedural texture information
  86411. * @returns a parsed Marble Procedural BABYLON.Texture
  86412. */
  86413. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86414. }
  86415. }
  86416. declare module BABYLON {
  86417. /** @hidden */
  86418. export var normalMapProceduralTexturePixelShader: {
  86419. name: string;
  86420. shader: string;
  86421. };
  86422. }
  86423. declare module BABYLON {
  86424. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86425. private _baseTexture;
  86426. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86427. updateShaderUniforms(): void;
  86428. render(useCameraPostProcess?: boolean): void;
  86429. resize(size: any, generateMipMaps: any): void;
  86430. get baseTexture(): BABYLON.Texture;
  86431. set baseTexture(texture: BABYLON.Texture);
  86432. /**
  86433. * Serializes this normal map procedural texture
  86434. * @returns a serialized normal map procedural texture object
  86435. */
  86436. serialize(): any;
  86437. /**
  86438. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86439. * @param parsedTexture defines parsed texture data
  86440. * @param scene defines the current scene
  86441. * @param rootUrl defines the root URL containing normal map procedural texture information
  86442. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86443. */
  86444. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86445. }
  86446. }
  86447. declare module BABYLON {
  86448. /** @hidden */
  86449. export var perlinNoiseProceduralTexturePixelShader: {
  86450. name: string;
  86451. shader: string;
  86452. };
  86453. }
  86454. declare module BABYLON {
  86455. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86456. time: number;
  86457. timeScale: number;
  86458. translationSpeed: number;
  86459. private _currentTranslation;
  86460. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86461. updateShaderUniforms(): void;
  86462. render(useCameraPostProcess?: boolean): void;
  86463. resize(size: any, generateMipMaps: any): void;
  86464. /**
  86465. * Serializes this perlin noise procedural texture
  86466. * @returns a serialized perlin noise procedural texture object
  86467. */
  86468. serialize(): any;
  86469. /**
  86470. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86471. * @param parsedTexture defines parsed texture data
  86472. * @param scene defines the current scene
  86473. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86474. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86475. */
  86476. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86477. }
  86478. }
  86479. declare module BABYLON {
  86480. /** @hidden */
  86481. export var roadProceduralTexturePixelShader: {
  86482. name: string;
  86483. shader: string;
  86484. };
  86485. }
  86486. declare module BABYLON {
  86487. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86488. private _roadColor;
  86489. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86490. updateShaderUniforms(): void;
  86491. get roadColor(): BABYLON.Color3;
  86492. set roadColor(value: BABYLON.Color3);
  86493. /**
  86494. * Serializes this road procedural texture
  86495. * @returns a serialized road procedural texture object
  86496. */
  86497. serialize(): any;
  86498. /**
  86499. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86500. * @param parsedTexture defines parsed texture data
  86501. * @param scene defines the current scene
  86502. * @param rootUrl defines the root URL containing road procedural texture information
  86503. * @returns a parsed Road Procedural BABYLON.Texture
  86504. */
  86505. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86506. }
  86507. }
  86508. declare module BABYLON {
  86509. /** @hidden */
  86510. export var starfieldProceduralTexturePixelShader: {
  86511. name: string;
  86512. shader: string;
  86513. };
  86514. }
  86515. declare module BABYLON {
  86516. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86517. private _time;
  86518. private _alpha;
  86519. private _beta;
  86520. private _zoom;
  86521. private _formuparam;
  86522. private _stepsize;
  86523. private _tile;
  86524. private _brightness;
  86525. private _darkmatter;
  86526. private _distfading;
  86527. private _saturation;
  86528. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86529. updateShaderUniforms(): void;
  86530. get time(): number;
  86531. set time(value: number);
  86532. get alpha(): number;
  86533. set alpha(value: number);
  86534. get beta(): number;
  86535. set beta(value: number);
  86536. get formuparam(): number;
  86537. set formuparam(value: number);
  86538. get stepsize(): number;
  86539. set stepsize(value: number);
  86540. get zoom(): number;
  86541. set zoom(value: number);
  86542. get tile(): number;
  86543. set tile(value: number);
  86544. get brightness(): number;
  86545. set brightness(value: number);
  86546. get darkmatter(): number;
  86547. set darkmatter(value: number);
  86548. get distfading(): number;
  86549. set distfading(value: number);
  86550. get saturation(): number;
  86551. set saturation(value: number);
  86552. /**
  86553. * Serializes this starfield procedural texture
  86554. * @returns a serialized starfield procedural texture object
  86555. */
  86556. serialize(): any;
  86557. /**
  86558. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86559. * @param parsedTexture defines parsed texture data
  86560. * @param scene defines the current scene
  86561. * @param rootUrl defines the root URL containing startfield procedural texture information
  86562. * @returns a parsed Starfield Procedural BABYLON.Texture
  86563. */
  86564. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86565. }
  86566. }
  86567. declare module BABYLON {
  86568. /** @hidden */
  86569. export var woodProceduralTexturePixelShader: {
  86570. name: string;
  86571. shader: string;
  86572. };
  86573. }
  86574. declare module BABYLON {
  86575. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86576. private _ampScale;
  86577. private _woodColor;
  86578. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86579. updateShaderUniforms(): void;
  86580. get ampScale(): number;
  86581. set ampScale(value: number);
  86582. get woodColor(): BABYLON.Color3;
  86583. set woodColor(value: BABYLON.Color3);
  86584. /**
  86585. * Serializes this wood procedural texture
  86586. * @returns a serialized wood procedural texture object
  86587. */
  86588. serialize(): any;
  86589. /**
  86590. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86591. * @param parsedTexture defines parsed texture data
  86592. * @param scene defines the current scene
  86593. * @param rootUrl defines the root URL containing wood procedural texture information
  86594. * @returns a parsed Wood Procedural BABYLON.Texture
  86595. */
  86596. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86597. }
  86598. }